UIView
的暗影設置重要經由過程UIView
的layer
的相干屬性來設置
暗影的色彩
imgView.layer.shadowColor = [UIColor blackColor].CGColor;
暗影的通明度
imgView.layer.shadowOpacity = 0.8f;
暗影的圓角
imgView.layer.shadowRadius = 4.f;
暗影偏移量
imgView.layer.shadowOffset = CGSizeMake(4,4);
imgView.layer.shadowOffset = CGSizeMake(0,0);
其實從偏移量上可以看出來,即便偏移量為(0,0)時,環繞view的周圍仍然能看到必定暗影。
暗影的途徑
除經由過程下面的操作,我們還可以設定暗影的途徑
//途徑暗影 UIBezierPath *path = [UIBezierPath bezierPath]; [path moveToPoint:CGPointMake(-5, -5)]; //添加直線 [path addL.netoPoint:CGPointMake(paintingWidth /2, -15)]; [path addL.netoPoint:CGPointMake(paintingWidth +5, -5)]; [path addL.netoPoint:CGPointMake(paintingWidth +15, paintingHeight /2)]; [path addLineToPoint:CGPointMake(paintingWidth +5, paintingHeight +5)]; [path addLineToPoint:CGPointMake(paintingWidth /2, paintingHeight +15)]; [path addLineToPoint:CGPointMake(-5, paintingHeight +5)]; [path addLineToPoint:CGPointMake(-15, paintingHeight /2)]; [path addLineToPoint:CGPointMake(-5, -5)]; //設置暗影途徑 imgView.layer.shadowPath = path.CGPath;
總結
以上就是這篇文章的全體內容,願望能對列位IOS開辟者們能有所贊助,假如有疑問年夜家可以留言交換。
【iOS為UIView設置暗影後果】的相關資料介紹到這裡,希望對您有所幫助! 提示:不會對讀者因本文所帶來的任何損失負責。如果您支持就請把本站添加至收藏夾哦!