您现在的位置: IOS教程網 >> IOS系統 >  >> iOS 程式開發 >> iOS 開發綜合

為 UIView 加入陰影效果的屬性與路徑設定

編輯:iOS 開發綜合

視圖陰影主要透過 layer 設定。

imgView.layer.shadowColor = [UIColor blackColor].CGColor;
imgView.layer.shadowOpacity = 0.8f;
imgView.layer.shadowRadius = 4.f;
imgView.layer.shadowOffset = CGSizeMake(4, 4);

即使偏移為 (0, 0),仍可能看到四周陰影。

自訂陰影路徑

若需要更精準的效能與外觀,可設定 shadowPath:

UIBezierPath *path = [UIBezierPath bezierPath];
// 依需求繪製路徑
imgView.layer.shadowPath = path.CGPath;

  1. 上一篇文章:
  2. 下一篇文章:
蘋果刷機越獄教程| IOS教程問題解答| IOS技巧綜合| IOS7技巧| IOS8教程
Copyright © IOS教程網 All Rights Reserved