标签:
UIButton *abutton=[UIButton buttonWithType:UIButtonTypeRoundedRect];
abutton.frame=CGRectMake(130, 230, 100, 40);
[abutton setImage:[UIImage imageNamed:@"button0_movieInfo.png"] forState:UIControlStateNormal];
[abutton setImage:[UIImage imageNamed:@"button1_movieInfo.png"] forState:UIControlStateHighlighted];
abutton.layer.cornerRadius=4.0;//按钮圆角半径
abutton.layer.masksToBounds=YES;//使圆角不被遮盖
//边框的颜色和宽度
abutton.layer.borderColor=[UIColor redColor].CGColor;
abutton.layer.borderWidth=1;
[abutton addTarget:self action:@selector(comein) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:abutton];
-setMasksToBounds:方法告诉layer将位于它之下的layer都遮盖住。这是必须的,这样会使圆角不被遮
标签:
原文地址:http://www.cnblogs.com/huangzs/p/4461002.html