环境 SDK 8.1的圆角按钮的实现

 

如下面代码写,按钮有圆角(背景红色)。

UIButton* _contentBtn = [UIButton buttonWithType:UIButtonTypeSystem];
[_contentBtn.layer setCornerRadius:8]; //圆角弧度
[_contentBtn setBackgroundColor:[UIColor redColor]];

备注:UIButtonTypeRoundedRect 已经 deprecated,请使用UIButtonTypeSystem来代替.