首页 > 其他分享 >CAShapeLayer 使用详解

CAShapeLayer 使用详解

时间:2023-05-24 13:07:07浏览次数:44  
标签:CAShapeLayer self height 详解 使用 shapeLayer singleLinePath frame size


CAShapeLayer 使用详解

//
//  JFProcessView.m
//  test_JFProcessView_01
//
//  Created by jeffasd on 16/7/4.
//  Copyright © 2016年 jeffasd. All rights reserved.
//

#import "JFProcessView.h"

@interface JFProcessView ()

@property (nonatomic, strong) CAShapeLayer *shapeLayer;



@end

@implementation JFProcessView

- (instancetype)initWithFrame:(CGRect)frame{
    
    self = [super initWithFrame:frame];
    
    if (self) {
        
        self.backgroundColor = [UIColor clearColor];
        
        [self initShapeLayer];
        
    }
    
    return self;
}

- (void)initShapeLayer{
    
    self.shapeLayer = [CAShapeLayer layer];
}

- (void)configUIWithFrame:(CGRect)frame{
    
//    self.shapeLayer = [CAShapeLayer layer];
//    self.shapeLayer.frame = self.bounds;
//    
    self.shapeLayer.lineWidth = self.frame.size.height;
//    
//    self.shapeLayer.lineWidth = 2;
//    
//    self.shapeLayer.fillColor = [UIColor redColor].CGColor;
//    self.shapeLayer.strokeColor = [UIColor orangeColor].CGColor;
//    self.shapeLayer.lineCap = kCALineCapRound;
//    UIBezierPath *singleLinePath = [[UIBezierPath alloc] init];
//    
//    
//    
    [singleLinePath moveToPoint:CGPointMake(0, self.frame.size.height/2)];
    [singleLinePath addLineToPoint:CGPointMake(self.frame.size.width, self.frame.size.height/2)];
//    
//    
//    
//    [singleLinePath moveToPoint:CGPointMake(0, 0)];
//    [singleLinePath addLineToPoint:CGPointMake(0, self.frame.size.height)];
//    [singleLinePath addArcWithCenter:CGPointMake(self.frame.size.width/2, self.frame.size.height) radius:self.frame.size.width/2 startAngle:0 endAngle:M_PI clockwise:YES];
//    [singleLinePath addLineToPoint:CGPointMake(0, self.frame.size.height)];
//    [singleLinePath moveToPoint:CGPointMake(0, self.frame.size.height)];
//    [singleLinePath addLineToPoint:CGPointMake(self.frame.size.width, self.frame.size.height)];
//    
//    
//    _shapeLayer.fillColor = [UIColor blueColor].CGColor;
//    _shapeLayer.path = singleLinePath.CGPath;
//    _shapeLayer.strokeStart = 0.0;
//    _shapeLayer.strokeEnd = 1.0;
//    [self.layer addSublayer:_shapeLayer];
    
//    self.shapeLayer = [CAShapeLayer layer];
        self.shapeLayer.frame = self.bounds;
    
//    self.shapeLayer.frame = CGRectMake(0, 200, 375, 500);
    
    //    self.shapeLayer.lineWidth = self.frame.size.height;
    
    self.shapeLayer.lineWidth = 2;
    
//    self.shapeLayer.fillColor = [UIColor redColor].CGColor;
    self.shapeLayer.strokeColor = [UIColor clearColor].CGColor;
    self.shapeLayer.lineCap = kCALineCapRound;
    UIBezierPath *singleLinePath = [[UIBezierPath alloc] init];
    
    
    
    //    [singleLinePath moveToPoint:CGPointMake(0, self.frame.size.height/2)];
    //    [singleLinePath addLineToPoint:CGPointMake(self.frame.size.width, self.frame.size.height/2)];
    
    
    int width = self.frame.size.width;
    
    int height = self.frame.size.height;
    
//    width = 300;
//    height = 30;
    
    int start = 0;
    
    [singleLinePath moveToPoint:CGPointMake(start, start)];
    [singleLinePath addLineToPoint:CGPointMake(width+start-height/2, 0+start)];
    [singleLinePath addArcWithCenter:CGPointMake(width+start-height/2, height/2+start) radius:height/2 startAngle:-M_PI/2 endAngle:M_PI/2 clockwise:YES];
    [singleLinePath addLineToPoint:CGPointMake(start, height+start)];
    [singleLinePath addLineToPoint:CGPointMake(start, start)];
    
    
    _shapeLayer.fillColor = [UIColor blueColor].CGColor;
    _shapeLayer.path = singleLinePath.CGPath;
    _shapeLayer.strokeStart = 0.0;
    _shapeLayer.strokeEnd = 1.0;
    [self.layer addSublayer:_shapeLayer];
    
}

- (void)setProgressTintColor:(UIColor *)progressTintColor{
    
//    self.shapeLayer.strokeColor = _progressTintColor.CGColor;
}

- (void)setTrackTintColor:(UIColor *)trackTintColor{
//    self.backgroundColor = trackTintColor;
}

@end




标签:CAShapeLayer,self,height,详解,使用,shapeLayer,singleLinePath,frame,size
From: https://blog.51cto.com/u_16124099/6338553

相关文章

  • JXLS使用
    JXLS是一个简单易用的一个用于生成和读入Excel的工具,有兴趣的朋友可以到Jxls的官网上面下载最新版本的Jxls,目前Jxls最新的版本是0.9.5,下载的Zip包里面有一个Doc和Example,不过,官网所提供的东西太过简单,如果,需要详细了解Jxls的功能和使用方法的话,可以仔细研究其源代码。将Jxls源代......
  • Spring MVC +MyBatis3全注解实例详解
    SpringMVC3.0.5+Spring3.0.5+MyBatis3.0.4全注解实例详解(一):[url]http://www.blogjava.net/bolo/archive/2011/05/23/349655.html[/url]如何配置Eclipse,Maven,Jetty并运行工程.如是使用Tomcat的话,改插件为:[url]http://tomcat.apache.org/maven-plugin......
  • javascript的 this 详解以及apply与call的用法意义及区别
    [color=red][b]关于JavaScript中apply与call的用法意义及区别[/b][/color][url]http://www.cnitblog.com/yemoo/archive/2007/11/30/37070.aspx[/url][color=red][b]JAVASCRIPTTHIS详解[/b][/color]在面向对象编程语言中,对于this关键字我们是非常熟悉的。比如C++、C#和Java等都......
  • 使用JPA+Struts2+Spring 在 google Appengine开发应用
    本文同时发表在我在googleAppengine上的搭建的博客:[url]http://blogfor11lu.appspot.com/articleaction_view.action?article.id=agtibG9nZm9yMTFsdXIPCxIHQXJ0aWNsZRjBtQMM[/url]之前用JDO和Struts2在googleAppengine上试着写了一个简单的blog程序,但我还是希望使用Spring......
  • 使用Maven管理Web工程
    使用命令创建webapp工程:到workdpace运行命令[b][color=red]mvnarchetype:create-DgroupId=com.pandy-DartifactId=MavenDemo-DarchetypeArtifactId=maven-archetype-webapp[/color][/b]使用maven构建web项目实例[url]http://hnzhoujunmei.iteye.com/......
  • 学习Maven的使用
    学习maven的使用:[url]http://fluagen.blog.51cto.com/146595/40086[/url]Maven试用手记----开始一个新的项目并编译和测试:[url]http://www.blogjava.net/lvdougao/articles/26827.html[/url]maven编译命令:[url]http://radio123.iteye.com/blog/1490......
  • 使用spring初始化器创建出来的gradle项目,gradle.build.ks文件extra报错的解决方法
    有关讨论:https://github.com/spring-io/initializr/issues/922https://github.com/spring-io/start.spring.io/issues/581springboot生成器:https://start.spring.io/......
  • Mininet拓扑构建与命令使用
    实验目的1、通过命令模拟创建SDN网络。2、深入了解Mininet的命令使用。3、学会使用网络构建启动参数、内部交互命令及外部运行参数。实验环境Mininet拓扑构建与命令使用实验拓扑如下图所示。设备名称软件环境硬件环境主机Mininet_2.2.0_desktop_cv1.1CPU:1核内......
  • iOS OpenGL ES FBO 帧缓存区 渲染缓存区详解
    原文地址:https://developer.apple.com/library/content/documentation/3DDrawing/Conceptual/OpenGLES_ProgrammingGuide/WorkingwithEAGLContexts/WorkingwithEAGLContexts.html#//apple_ref/doc/uid/TP40008793-CH103-SW6绘制到其他渲染目的地Framebuffer对象是渲染命令的目标。......
  • BeanUtils使用总结
    [color=red][size=x-large]Commons-BeanUtils学习笔记[/size][/color[color=red][b]1、BeanUtils一共分4个包:[/b][/color][b]org.apache.commons.beanutilsorg.apache.commons.beanutils.convertersorg.apache.commons.beanutils.localeorg.apache.commons.beanutils.loc......