zoukankan      html  css  js  c++  java
  • iOS 设置按钮圆角(4个角都可随意设置)

    https://yq.aliyun.com/ziliao/4779

    设置按钮的4个角:
    左上:UIRectCornerTopLeft
    左下:UIRectCornerBottomLeft
    右上:UIRectCornerTopRight
    右下:UIRectCornerBottomRight

    例子代码:

    UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(50, 60, 80, 40)];
    button.backgroundColor = [UIColor orangeColor];
    [self.view addSubview:button];
     
    //这里设置的是左上和左下角
    UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:button.bounds   byRoundingCorners:UIRectCornerBottomLeft |    UIRectCornerTopLeft    cornerRadii:CGSizeMake(8, 8)];
    CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
    maskLayer.frame = button.bounds;
    maskLayer.path = maskPath.CGPath;
    button.layer.mask = maskLayer;

    效果图:

  • 相关阅读:
    数论2&莫&杜
    虚树学习笔记
    LinkCutTree学习笔记
    FWT学习笔记
    容斥
    线段树合并
    线性基
    FFT_应用和例题
    斜率优化
    Redis中String的底层实现
  • 原文地址:https://www.cnblogs.com/gaozhang12345/p/8421485.html
Copyright © 2011-2022 走看看