zoukankan      html  css  js  c++  java
  • UIView圆角设置

    对于UIview的圆角设置最简单的就是layer的两个属性分别是cornerRadius和masksToBounds,但是对于设置其中某一个角为圆角的时候需要使用贝塞尔曲线

    UIView *aView = [[UIView alloc] init];

    aView.frame = CGRectMake(0, 0, 300, 200);

    aView.backgroundColor = [UIColor redColor];

    [self.view addSubview:aView];

    //设置所需的圆角位置以及大小 UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:aView.bounds byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight cornerRadii:CGSizeMake(10, 10)];

    CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];

    maskLayer.frame = aView.bounds;

    maskLayer.path = maskPath.CGPath;

    aView.layer.mask = maskLayer;

    其中UIRectCornerBottomLeft 和UIRectCornerBottomRight,是一个枚举,里面还包括左上角和右上角
    但是再某些时候这么设置圆角,对于应用的来说会很占用资源,所以就要实现比较麻烦的贝塞尔曲线了。

  • 相关阅读:
    Scrum Meeting 11.11
    Scrum Meeting 11.10
    Scrum Meeting 11.09
    Scrum Meeting 11.08
    Scrum Meeting 11.07
    Scrum Meeting 11.06
    Scrum Meeting 11.05
    Scrum Meeting 11.04
    团队博客-应用功能说明书
    Scrum Meeting 11.03
  • 原文地址:https://www.cnblogs.com/Acee/p/4981667.html
Copyright © 2011-2022 走看看