• iOS textView设置一个直角三个圆角边框效果


    问题描述:实现以下的图片效果,实现左上角直角其余都为直角

    思路一:设置下层的这种圆直角图片或者view视图(不建议使用);

    思路二:实现父类textView,在父类的drawRect方法实现贝塞尔曲线方法

    代码:

    父类textView

    - (void)drawRect:(CGRect)rect {
        
      //设置背景 [[UIColor redColor] setFill];
    // Drawing code //绘制圆角 UIBezierPath * bezierPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds byRoundingCorners:(UIRectCornerTopRight |UIRectCornerBottomLeft | UIRectCornerBottomRight) cornerRadii:CGSizeMake(20.0f, 20.0f)]; [bezierPath fill];

      补充://设置边框样式颜色
    //    [[UIColor redColor] setStroke];
        // Drawing code
        //绘制圆角
    //    UIBezierPath * bezierPath = [UIBezierPath bezierPathWithRoundedRect:self.bounds  byRoundingCorners:(UIRectCornerTopRight |UIRectCornerBottomLeft | UIRectCornerBottomRight) cornerRadii:CGSizeMake(20.0f, 20.0f)];
    //    bezierPath.lineWidth = 1;
    //    [bezierPath stroke];
    }

    使用:

    textView = [[LayerTextView alloc]initWithFrame:CGRectMake(10, 100, widthAll-20, 200)];
    textView.text = @"测试设置textview圆直角";
    [self.view addSubview:textView];

    相关问题连接:http://www.cocoachina.com/bbs/read.php?tid=261853

    贝塞尔曲线介绍:http://blog.csdn.net/linpeng_1/article/details/50619754

  • 相关阅读:
    腾讯2016年实习生笔试题-蛇形数组-循环枚举遍历
    直接插入排序的加强版
    scanner 在java中的输入
    一种排序
    将string str中的str转换成字符数组
    呜呜呜
    ansible-playbook 实战案例 全网备份 实时备份
    Rsync服务实战
    TCP三次握手与四次握手
    centos 6.9修改系统默认字符集
  • 原文地址:https://www.cnblogs.com/wusang/p/6585818.html
Copyright © 2020-2023  润新知