zoukankan      html  css  js  c++  java
  • Button倒角,单边角,多边角

     最近有个ui的同事抱怨说她公司的前段开发动不动就让她切个小图,理由是实现不了,像下面这种小功能:

    其实这也是按钮的倒圆角,并不难。上代码:

    .h

    #import <UIKit/UIKit.h>

     

    @interface YMBtnCorner : UIButton

     

    //左上角

    - (void)ym_rectCorner:(CGFloat)radius conrners:(UIRectCorner)corners;

     

    @end

    .m

    #import "YMBtnCorner.h"

     

    @implementation YMBtnCorner

     

    - (void)ym_rectCorner:(CGFloat)radius conrners:(UIRectCorner)corners

    {

        UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds byRoundingCorners:corners cornerRadii:CGSizeMake(radius, radius)];

        

        CAShapeLayer *maskLayer = [CAShapeLayer layer];

        maskLayer.frame = self.bounds;

        maskLayer.path = maskPath.CGPath;

        

        self.layer.mask = maskLayer;

    }

     

    @end

    用法:

        //左上

        [self.topLeftCorner ym_rectCorner:10.0 conrners:UIRectCornerTopLeft];

        //左下

        [self.bottomLeftcorner ym_rectCorner:10 conrners:UIRectCornerBottomLeft];

        //右上

        [self.topRightCorner ym_rectCorner:10 conrners:UIRectCornerTopRight];

        //右下

        [self.bottomRightCorner ym_rectCorner:10 conrners:UIRectCornerBottomRight];

        //四个角

        [self.allCorner ym_rectCorner:10 conrners:UIRectCornerAllCorners];

        //左右上角

        [self.topLeftRightCorner ym_rectCorner:10 conrners:UIRectCornerTopRight | UIRectCornerTopLeft];

        //左右下角

        [self.bottomLeftRightCorner ym_rectCorner:10 conrners:UIRectCornerBottomRight | UIRectCornerBottomLeft];

        //左上右下

        [self.topLeftBottomRight ym_rectCorner:10 conrners:UIRectCornerTopLeft | UIRectCornerBottomRight];

        //左下右上

        [self.bottomLeftTopRight ym_rectCorner:10 conrners:UIRectCornerBottomLeft | UIRectCornerTopRight];

        //左边

        [self.leftCorner ym_rectCorner:10 conrners:UIRectCornerBottomLeft | UIRectCornerTopLeft];

        //右边

        [self.rightCorner ym_rectCorner:10 conrners:UIRectCornerBottomRight | UIRectCornerTopRight];

  • 相关阅读:
    计总与排名SUM和RANK函数
    计算获取最小值和最大值
    列值中获取第一个非空的值
    连续数字使用连接符替换
    展开中断或忽略的序号
    以连接字符截取字符串
    逗号分割字符串经存储过程存入数据表中
    符号分割的字符串转换为XML
    MS SQL Server的STRING_SPLIT和STRING_AGG函数
    MS SQL Server的LTRIM,RTRIM和TRIM函数
  • 原文地址:https://www.cnblogs.com/ljj-Andrew-519/p/9118045.html
Copyright © 2011-2022 走看看