UIImageView和UIButton的边框设置

imageView是UIIamgeView

//边框的颜色
imageView.layer.borderColor = [UIColor whiteColor].CGColor;
//边框的宽度
imageView.layer.borderWidth = 5;

confirmBtn是UIButton

//边框的宽度
[self.confirmBtn.layer setBorderWidth:1];
//边框的颜色
CGColorRef color = [UIColor orangeColor].CGColor;
[self.confirmBtn.layer setBorderColor:color];

//btn的内容剧中
confirmBtn.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
confirmBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;

你可能感兴趣的:(UIImageView和UIButton的边框设置)