zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    课后作业-阅读任务-阅读提问-4
    团队-象棋游戏-开发文档
    团队-象棋游戏-模块测试过程
    团队编程项目作业3-模块开发过程
    团队-象棋游戏-项目进度
    团队编程总结
    团队编程项目作业,维护
    个人编程总结2
    阅读笔记4
    课后提问4
  • 原文地址:https://www.cnblogs.com/wusang/p/6585818.html
Copyright © 2011-2022 走看看