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
  • 相关阅读:
    OpenFileMapping
    findwindow
    CopyMemory
    SetWindowsHookEx
    fillchar
    什么是ashx文件
    WPF中的控件
    WPF X名称空间里都有什么
    XAML语法学习之...
    Repeater控件使用总结
  • 原文地址:https://www.cnblogs.com/helmsyy/p/5430686.html
Copyright © 2011-2022 走看看