ios 按鈕或圖片框圓角處理

圖片框圓角處理(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;

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章