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

  • 相关阅读:
    1503: [NOI2004]郁闷的出纳员
    2049: [Sdoi2008]Cave 洞穴勘测
    2301: [HAOI2011]Problem b
    BZOJ 1923: [Sdoi2010]外星千足虫
    BZOJ 2115: [Wc2011] Xor
    POJ 1830 开关问题
    欧拉函数基础
    BZOJ 2186 沙拉公主的困惑
    POJ 1845
    逆元基础知识整理
  • 原文地址:https://www.cnblogs.com/wusang/p/6585818.html
Copyright © 2011-2022 走看看