圆形的View或者是button

//先定义一个UIView      

  UIView * view = [[UIView alloc] initWithFrame:CGRectMake(50, 50, 50, 50)];

//圆的半径是view宽的一半        

view.layer.cornerRadius = view.frame.size.width / 2;

//是否进行剪切        

view.clipsToBounds = YES;

//   给view一个颜色

    view.backgroundColor = [UIColor redColor];

//添加到视图上

[self.View addSubview:view];

 

//UIButton

UIButton * = [UIButton buttonWithType:(UIButtonTypeRoundedRect)];

    button.frame =CGRectMake(10, 10, 50, 50);

    button.layer.cornerRadius = button.frame.size.width /2;

    button.clipsToBounds = YES;

[self.view addSubview:button];

 

posted @ 2016-03-15 10:53  胡胡同学  阅读(160)  评论(0编辑  收藏  举报