給UIImageView新增陰影和邊框

2021-06-08 21:58:47 字數 1139 閱讀 9880

給uiimageview新增陰影和邊框

uiimageview

*_iconview = [[

uiimageview

alloc

] init];

//新增邊框

calayer

*layer = [_iconview

layer];

layer.

bordercolor

= [[

uicolor

whitecolor

] cgcolor];

layer.

borderwidth

= 5.0f;

//新增四個邊陰影

_iconview

.layer

.shadowoffset

= cgsizemake

(0.0f

, 0.0f);

_iconview

.layer

.shadowopacity

= 0.5;

_iconview

.layer

.shadowradius

= 10.0;

_iconview

.layer

.shadowcolor

= [[

uicolor

redcolor

] cgcolor];

//新增兩個邊陰影

_iconview

.layer

.shadowoffset

= cgsizemake

(4.0f

, 4.0f);

_iconview

.layer

.shadowopacity

= 0.5;

_iconview

.layer

.shadowradius

= 2.0;

_iconview

.layer

.shadowcolor

= [[

uicolor

redcolor

] cgcolor

];

給UIImageview 新增邊框 或者設定成圓角

設定layer calayer layer backview layer 是否設定邊框以及是否可見 layer setmaskstobounds yes 設定邊框圓角的弧度 layer setcornerradius 10.0 設定邊框線的寬 layer setborderwidth 1 設定邊框線...

給UIImageView新增點選事件

uiimageview imageview1 uiimageview alloc initwithframe cgrectmake 125,50,229,229 imageview1 setimage uiimage imagewithcontentsoffile path imageview1.u...

給UIImageview 新增邊框或者設定成圓角

分類 iphone plain view plain copy 設定layer calayer layer backview layer 是否設定邊框以及是否可見 layer setmaskstobounds yes 設定邊框圓角的弧度 layer setcornerradius 10.0 設定邊框...