利用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];


 

posted @ 2013-07-12 18:45  爱生活,爱编程  阅读(495)  评论(0编辑  收藏  举报