UIButton,设置为UIButtonTypeCustom类型时,做圆角效果

来源:互联网 发布:如何办网络授权书 编辑:程序博客网 时间:2024/06/16 09:00
 Add QuartzCore.framework to your project and this line to your .m file. 
      #import <QuartzCore/QuartzCore.h> 

示例代码如下: 
     
  1. UIButton *moreButton = [UIButton buttonWithType:UIButtonTypeCustom];  
  2.       moreButton.frame = CGRectMake(1.0f, 1.0f, cell.contentView.frame.size.width-2, cell.contentView.frame.size.height-2);  
  3.       [moreButton.layer setMasksToBounds:YES];  
  4.       [moreButton.layer setCornerRadius:10.0]; //设置矩形四个圆角半径  
  5.       [moreButton.layer setBorderWidth:1.0]; //边框宽度  
  6.       moreButton.backgroundColor = [UIColor clearColor];  

原文地址:http://stackoverflow.com/questions/7813379/what-does-receiver-type-calayer-for-instance-message-is-a-forward-declaration
原创粉丝点击