利用UIBezierPath实现一个带圆角的视图

- (void)drawRect:(CGRect)rect
{
    // draw a box with rounded corners to fill the view -
    UIBezierPath *roundedRect = [UIBezierPath bezierPathWithRoundedRect:self.bounds cornerRadius:5.0f];
    [[UIColor colorWithWhite:0.8 alpha:0.5] setFill];
    [roundedRect fillWithBlendMode:kCGBlendModeNormal alpha:1];
}


UIBezierPath对象是CGPathRef数据类型的封装。path如果是基于矢量形状的,都用直线和曲线段去创建。我们使用直线段去创建矩形和多边形,使用曲线段去创建弧(arc),圆或者其他复杂的曲线形状。

 

UIBezierPath 的使用介绍  

详细的介绍了UIBezierPath ,这里我就不多说了!


  // 通过UINib 加载xib资源文件
  UINib *hoverViewXib = [UINib nibWithNibName:@"xxxx" bundle:nil];
 [hoverViewXib instantiateWithOwner:self options:nil];


原文地址:https://www.cnblogs.com/snake-hand/p/3186917.html