文章目录
  1. 1. iOS image button setCornerRadius

iOS image button setCornerRadius

当我们在button上添加背景图片和背景颜色的时候就会发现,setCornerRadius这个属性并不适用,因为现在的button已经不是圆角的了,它显示的是图片的形状,当设置背景颜色设置为UIButtonTypeCustom属性才可以显示出来。所以我们需要用UIButton控件的其它属性来满足我们的需求

[self.headerBtn setImage:[UIImage imageNamed:@”mine_000”] forState:UIControlStateNormal];
    [self.headerBtn.layer setMasksToBounds:YES];
[self.headerBtn.layer setCornerRadius:40.0f];//圆角

Use this for convert UIImage to NSData.

  NSData *imagedata = UIImagePNGRepresentation(thumbnail);

Try this for image data convert back to UIImage

  UIImage *image= [UIImage imageWithData:imagedata];

文章目录
  1. 1. iOS image button setCornerRadius