你好,歡迎來到IOS教程網

 Ios教程網 >> IOS編程開發 >> IOS開發綜合 >> IOS開發之為視圖繪制單(多)個圓角實例代碼

IOS開發之為視圖繪制單(多)個圓角實例代碼

編輯:IOS開發綜合

IOS開發之為視圖繪制單(多)個圓角實例代碼

前言:

為視圖繪制圓角,圓角可以選左上角、左下角、右下角、右上角、全部圓角

//Core Raduias

UIView *actionView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 200, 200)];
UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:actionView.bounds byRoundingCorners:UIRectCornerTopRight | UIRectCornerBottomRight cornerRadii:CGSizeMake(20, 20)];
CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
maskLayer.frame = actionView.bounds;
maskLayer.path = maskPath.CGPath;
actionView.layer.mask = maskLayer;

UIRectCorner枚舉值如下:

typedef NS_OPTIONS(NSUInteger, UIRectCorner) {

  UIRectCornerTopLeft   = 1 << 0,
  UIRectCornerTopRight  = 1 << 1,
  UIRectCornerBottomLeft = 1 << 2,
  UIRectCornerBottomRight = 1 << 3,
  UIRectCornerAllCorners = ~0UL
};

感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!

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