ios 按钮或图片框圆角处理

来源:互联网 发布:linux usermod ag 编辑:程序博客网 时间:2024/05/22 06:49
图片框圆角处理(UIImageView):
导入库头文件(重点)
#import <QuartzCore/QuartzCore.h>


 /// 设置圆形 cornerRadius 如果为圆形 ,则为 宽或高的一半

        imageView.layer.masksToBounds =YES;

        

       CGFloat w = imageView.frame.size.width /2;

        imageView.layer.cornerRadius = w;

        

        //边框宽度及颜色设置

        [imageView.layersetBorderWidth:2];

        [imageView.layersetBorderColor:[[UIColorblueColor]CGColor]];

        



 

//圆角设置
imageView.layer.cornerRadius = 6;
imageView.layer.masksToBounds = YES;





//边框宽度及颜色设置
[imageView.layer setBorderWidth:2];
[imageView.layer setBorderColor:[UIColor blueColor]];  //设置边框为蓝色

//自动适应,保持图片宽高比
imageView.contentMode = UIViewContentModeScaleAspectFit;

0 0
原创粉丝点击