zoukankan      html  css  js  c++  java
  • iOS开发之指定UIView的某几个角为圆角

    使用UIBezierPath。下面给出一段示例代码。

     1 UIView *view2 = [[UIView alloc] initWithFrame:CGRectMake(120, 10, 80, 80)];
     2 view2.backgroundColor = [UIColor redColor];
     3 [self.view addSubview:view2];
     4 
     5 UIBezierPath maskPath = [UIBezierPath bezierPathWithRoundedRect:view2.bounds byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight cornerRadii:CGSizeMake(10, 10)];
     6 CAShapeLayer maskLayer = [[CAShapeLayer alloc] init];
     7 maskLayer.frame = view2.bounds;
     8 maskLayer.path = maskPath.CGPath;
     9 view2.layer.mask = maskLayer;
    10 
    11 
    12 //指定了需要成为圆角的角。该参数是UIRectCorner类型的,可选的值有:
    13 
    14 * UIRectCornerTopLeft
    15 * UIRectCornerTopRight
    16 * UIRectCornerBottomLeft
    17 * UIRectCornerBottomRight
    18 * UIRectCornerAllCorners
  • 相关阅读:
    软件设计文档
    java基础路线与详细知识点
    hdu 2203 亲和串 kmp
    UVALive 6915 J
    UVALive 6911 F
    UVALive 6906 A
    hdu 3746 Cyclic Nacklace KMP
    hdu 1686 Oulipo kmp算法
    hdu1711 Number Sequence kmp应用
    hdu4749 kmp应用
  • 原文地址:https://www.cnblogs.com/helmsyy/p/5430686.html
Copyright © 2011-2022 走看看