1
如何在具有圓角的UIButton中添加右側和左側邊框?在帶圓角的UIButton中添加底部邊框
這是我的按鈕,我想圓角邊框太:
我的按鈕的源代碼:
- (void)initialise;
{
//add border
[self addBottomBorderWithColor:[UIColor grayColor] andWidth:2];
[self addRightBorderWithColor:[UIColor grayColor] andWidth:2];
//round
self.layer.cornerRadius = 8.0f;
}
- (void)addTopBorderWithColor:(UIColor *)color andWidth:(CGFloat) borderWidth
{
CALayer *border = [CALayer layer];
border.backgroundColor = color.CGColor;
border.frame = CGRectMake(0, 0, self.frame.size.width, borderWidth);
[self.layer addSublayer:border];
}
- (void)addRightBorderWithColor:(UIColor *)color andWidth:(CGFloat) borderWidth
{
CALayer *border = [CALayer layer];
border.backgroundColor = color.CGColor;
border.frame = CGRectMake(self.frame.size.width, 0, borderWidth, self.frame.size.height);
[self.layer addSublayer:border];
}
怎麼樣自動佈局?在旋轉設備的情況下,您需要更改CALayer幀。 – TomSawyer