UIBezierPath简单实现带箭头view

自定义一个view,在里面划线添加ui

#import "BeazView.h"

@implementation BeazView

-(instancetype)initWithFrame:(CGRect)frame{

self = [super initWithFrame:frame];

if (self) {

[self dosomething];

}

return self;

}

-(void)dosomething{

_bezierPath4 = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(10, 20, self.frame.size.width-20, 100) byRoundingCorners:UIRectCornerAllCorners

cornerRadii:CGSizeMake(10, 10)];

[_bezierPath4 moveToPoint:CGPointMake(100, 0)];

[_bezierPath4 addLineToPoint:CGPointMake(80, 20)];

[_bezierPath4 addLineToPoint:CGPointMake(120, 20)];

_shaperLayer4 = [CAShapeLayer new];

_shaperLayer4.fillColor = [UIColor orangeColor].CGColor;

[self.layer addSublayer:_shaperLayer4];

_shaperLayer4.path = _bezierPath4.CGPath;

_title = [[UILabel alloc]initWithFrame:CGRectMake(10, 20, self.frame.size.width-20, 100)];

_title.text = @"我在上面";

_title.textColor = [UIColor redColor];

[self addSubview:_title];

}



定义一个按钮,实现移除

[UIView animateWithDuration:0.02 animations:^{

[view removeFromSuperview];

} completion:^(BOOL finished) {

}];

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • *7月8日上午 N:Block :跟一个函数块差不多,会对里面所有的内容的引用计数+1,想要解决就用__block...
    炙冰阅读 7,347评论 1 14
  • Quartz2D以及drawRect的重绘机制字数1487 阅读21 评论1 喜欢1一、什么是Quartz2D Q...
    PurpleWind阅读 4,251评论 0 3
  • 温柔的谦卑 手捧埃克哈特·托儿《新世界》一书,很像遇到一位可心的知友,书中很多观点,颇有共鸣。我想这可能是因为我们...
    绿阶窗前草不除阅读 1,774评论 0 0
  • 不图一时 只图一世 时光飞逝,猴年仅剩下两个月的时光。年关将近,而陈先生的董小姐还在游离,是因为他的家里没有草原吗...
    陈亚墨阅读 4,581评论 1 6
  • 如何调试 IE 浏览器1 安装高版本IE浏览器,如安装的是IE9,则可以直接调试IE9、IE8、IE72 IE...
    coolheadedY阅读 4,172评论 2 1

友情链接更多精彩内容