zoukankan      html  css  js  c++  java
  • 增加view的圆角笔记

       iOS开发中,常常由于需求,而需要圆角的样式.如果4个角都是圆角的,还好说.一行两行代码就可以搞定.就是CAlayer.可是现在我想说下不规则的圆角.目前我还没有找到更好的方法来画圆角.希望有解决方法的朋友看到这篇文章,能交流学习下.

    copycode.gif

    1     UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:sourceView.bounds byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerTopLeft cornerRadii:CGSizeMake(5, 5)];

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

    3     maskLayer.frame = sourceView.bounds;

    4     maskLayer.path = maskPath.CGPath;

    5     sourceView.layer.mask = maskLayer;

    号称是最优雅的画不定圆角视图的方法.想画哪个圆角就在bezierPathWithRoundedRect:byRoundingCorners: 方法中添加相应枚举值就行了.如下图(左侧图标的左圆角就是用这种方法切的.):

  • 相关阅读:
    5,7地面物品
    0,1选怪
    0,2使用红,蓝
    BT地址(__)
    3,7包裹物品数组
    0,4捡物
    如何在目标内网中发现更多存活主机
    xss自动化攻击
    .NET Framework 4安装失败
    利用struts1.x框架需要注意的问题
  • 原文地址:https://www.cnblogs.com/shenshanyikuchai/p/4313825.html
Copyright © 2011-2022 走看看