UIButton *signBtn = [UIButton buttonWithType:UIButtonTypeCustom]
signBtn.frame = CGRectMake(0, 0, 80, 40)
[signBtn.layer setMasksToBounds:YES]
[signBtn.layer setCornerRadius:10.0]
//设置矩形四个圆角半径
[signBtn.layer setBorderWidth:1.0]
//边框宽度
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB()
CGColorRef colorref = CGColorCreate(colorSpace,(CGFloat[]){ 1, 0, 0, 1 })
[signBtn.layer setBorderColor:colorref]
//边框颜色.
刚刚找到答案:
UIColor *taskColor = [UIColor colorWithRed:0.98f green:0.92f blue:0.80f alpha:1.0f]
UIButton *taskBtn = [[UIButton alloc] initWithFrame:CGRectMake(40, 150, 280, 160)]
taskBtn.backgroundColor = taskColor
CALayer *bottomBorder = [CALayer layer]
float height=taskBtn.frame.size.height-1.0f
float width=taskBtn.frame.size.width
bottomBorder.frame = CGRectMake(0.0f, height, width, 1.0f)
bottomBorder.backgroundColor = [UIColor redColor].CGColor
[taskBtn.layer addSublayer:bottomBorder]
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)