├── .gitignore ├── .travis.yml ├── Assets ├── YXYDashLayer.PNG └── YXYDashLayer.gif ├── LICENSE ├── README.md ├── Source ├── YXYColorfulDashLayer.h ├── YXYColorfulDashLayer.m ├── YXYMaskDashLayer.h ├── YXYMaskDashLayer.m ├── YXYProgressDashLayer.h └── YXYProgressDashLayer.m ├── YXYDashLayer.podspec └── YXYDashLayerSample ├── YXYDashLayerKit ├── Info.plist └── YXYDashLayerKit.h ├── YXYDashLayerSample.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ ├── contents.xcworkspacedata │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist └── xcshareddata │ └── xcschemes │ ├── YXYDashLayerKit.xcscheme │ └── YXYDashLayerSample.xcscheme └── YXYDashLayerSample ├── AppDelegate.h ├── AppDelegate.m ├── Assets.xcassets ├── AppIcon.appiconset │ └── Contents.json └── Contents.json ├── Base.lproj ├── LaunchScreen.storyboard └── Main.storyboard ├── Info.plist ├── ViewController.h ├── ViewController.m └── main.m /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata/ 19 | 20 | ## Other 21 | *.moved-aside 22 | *.xccheckout 23 | *.xcscmblueprint 24 | 25 | ## Obj-C/Swift specific 26 | *.hmap 27 | *.ipa 28 | *.dSYM.zip 29 | *.dSYM 30 | 31 | # CocoaPods 32 | # 33 | # We recommend against adding the Pods directory to your .gitignore. However 34 | # you should judge for yourself, the pros and cons are mentioned at: 35 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 36 | # 37 | # Pods/ 38 | 39 | # Carthage 40 | # 41 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 42 | # Carthage/Checkouts 43 | 44 | Carthage/Build 45 | 46 | # fastlane 47 | # 48 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 49 | # screenshots whenever they are needed. 50 | # For more information about the recommended setup visit: 51 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 52 | 53 | fastlane/report.xml 54 | fastlane/Preview.html 55 | fastlane/screenshots 56 | fastlane/test_output 57 | 58 | # Code Injection 59 | # 60 | # After new code Injection tools there's a generated folder /iOSInjectionProject 61 | # https://github.com/johnno1962/injectionforxcode 62 | 63 | iOSInjectionProject/ 64 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | osx_image: xcode9.3 2 | language: objective-c 3 | xcode_project: YXYDashLayerSample 4 | xcode_scheme: YXYDashLayerKit 5 | xcode_sdk: iphoneos11.3 6 | env: 7 | global: 8 | - FRAMEWORK_NAME=YXYDashLayerKit 9 | before_install: 10 | - brew update 11 | - brew outdated carthage || brew upgrade carthage 12 | before_script: 13 | before_deploy: 14 | - carthage build --no-skip-current 15 | - carthage archive $FRAMEWORK_NAME 16 | script: xcodebuild -project YXYDashLayerSample/YXYDashLayerSample.xcodeproj -scheme YXYDashLayerSample 17 | -configuration Release -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO 18 | deploy: 19 | provider: releases 20 | api_key: 21 | secure: JkfrHAdFxyUGwLqn/JJpwz2ys6KTpz9jaHLJO9RKZLxQfQrQxjwcBEud8nbZW3xOvDC2C6zn1JcRsfx/tL7dunGAemN8vDoUm6MkL5US7f3H2B4iVIbDILxZZjJJffyJ4DNGSnmWKqO2TM64qltqOXpbtwCTlhY0YgusUnMBYvQ/lMKM3goZb3Y5Xl4nryVIIFkV7gz4TVPoPc4RUr7OsbRY+XmeIbJseF3S3NPF7k0nQSE51cy9ykx69fKovCfg4xaTIBUFmekT04ObrgGaXhbXkY05numrmL3olX54RzeUC7ebveBescZXY8L35ueBCE6c0MkaV5COKLdDJdH5zkA4cBySD5JRvC6a5rZ6u4w2IVxuMLqBvlTpg+8dEFj1pKrGpfh04molSfAUyrwODkxSGOuK8MTUtohHaNiwmuYnsEv87+YHAP7pt36ppsGsKzkhWF8yF3yLamFHSZEHrRpOmzt9Th7tf/E5K877ot1Jyow8xTrYP/y2WoCzqRK6YSQlGrl9cTk5Wy41Lc0dys7ubNK/1yJjOb3beBCNUlzGsBtE45JKMf3H2GSv/XR1RDX+ASwTsht3T4bPK91SnHOWkIcxL+PYH4Fketxg6wXoPfTJItZPO6MGvWHAqfwi/ru1/2lZ8mACYyuj2XzXnUTQREnxko2Pn3bhcd5a8uc= 22 | file: YXYDashLayerKit.framework.zip 23 | skip_cleanup: true 24 | on: 25 | repo: yulingtianxia/YXYDashLayer 26 | tags: true 27 | -------------------------------------------------------------------------------- /Assets/YXYDashLayer.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yulingtianxia/YXYDashLayer/56790f7fdbfda46dedf303980e1ef66d40008035/Assets/YXYDashLayer.PNG -------------------------------------------------------------------------------- /Assets/YXYDashLayer.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/yulingtianxia/YXYDashLayer/56790f7fdbfda46dedf303980e1ef66d40008035/Assets/YXYDashLayer.gif -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 杨萧玉 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Build Status](https://travis-ci.org/yulingtianxia/YXYDashLayer.svg?branch=master)](https://travis-ci.org/yulingtianxia/YXYDashLayer) 2 | [![Version](https://img.shields.io/cocoapods/v/YXYDashLayer.svg?style=flat)](http://cocoapods.org/pods/YXYDashLayer) 3 | [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) 4 | [![License](https://img.shields.io/cocoapods/l/YXYDashLayer.svg?style=flat)](http://cocoapods.org/pods/YXYDashLayer) 5 | [![Platform](https://img.shields.io/cocoapods/p/YXYDashLayer.svg?style=flat)](http://cocoapods.org/pods/YXYDashLayer) 6 | [![CocoaPods](https://img.shields.io/cocoapods/dt/YXYDashLayer.svg)](http://cocoapods.org/pods/YXYDashLayer) 7 | [![CocoaPods](https://img.shields.io/cocoapods/at/YXYDashLayer.svg)](http://cocoapods.org/pods/YXYDashLayer) 8 | [![Twitter Follow](https://img.shields.io/twitter/follow/yulingtianxia.svg?style=social&label=Follow)](https://twitter.com/yulingtianxia) 9 | 10 | # YXYDashLayer 11 | 12 | `YXYProgressDashLayer` is composed of `YXYColorfulDashLayer`, which is masked by `YXYMaskDashLayer`. They can draw dash rounded rects. 13 | 14 | `YXYMaskDashLayer` controls the dash path. `YXYColorfulDashLayer` is a subclass of `CAGradientLayer`, so it can draw colorful dash path. `YXYProgressDashLayer` uses two instances of `YXYColorfulDashLayer`. 15 | 16 | ## 📚 Article 17 | 18 | [Colorful Rounded Rect Dash Border](http://yulingtianxia.com/blog/2018/04/30/Colorful-Rounded-Rect-Dash-Border/) 19 | 20 | ## 🐒 Usage 21 | 22 | ![](Assets/YXYDashLayer.gif) 23 | 24 | ``` 25 | self.progressDash = [YXYProgressDashLayer layer]; 26 | self.progressDash.underLayer.colors = @[(id)[UIColor blueColor].CGColor, (id)[UIColor greenColor].CGColor]; 27 | self.progressDash.progressColor = [UIColor grayColor]; 28 | 29 | CGFloat radius = self.cornerRadiusSlider.value; 30 | self.progressDash.dashCornerRadius = radius; 31 | 32 | CGFloat dashGap = self.dashGapSlider.value; 33 | self.progressDash.dashGap = dashGap; 34 | 35 | CGFloat dashWidth = self.dashWidthSlider.value; 36 | self.progressDash.dashWidth = dashWidth; 37 | 38 | NSInteger count = self.totalCountSlider.value; 39 | self.progressDash.totalCount = count; 40 | 41 | self.progressDash.progress = self.grayCountSlider.value; 42 | 43 | CGRect dashRect = CGRectMake((self.view.frame.size.width - 200) / 2, 50, 200, 300); 44 | self.progressDash.frame = dashRect; 45 | [self.progressDash refresh]; 46 | [self.view.layer addSublayer:self.progressDash]; 47 | ``` 48 | 49 | For better performance, you can use `refreshProgress` after modifying `totalCount`、`dashGap` and `progress`. NOTE: `refresh` must be called when `frame`, `dashWidth` or `dashCornerRadius` changes. 50 | 51 | ![](Assets/YXYDashLayer.PNG) 52 | 53 | ``` 54 | CGRect dashRect = CGRectMake((self.view.frame.size.width - 200) / 2, 50, 200, 300); 55 | YXYColorfulDashLayer *layer1 = [YXYColorfulDashLayer layer]; 56 | layer1.colors = @[(id)[UIColor blueColor].CGColor, (id)[UIColor redColor].CGColor, (id)[UIColor greenColor].CGColor]; 57 | layer1.totalCount = 16; 58 | layer1.dashCornerRadius = 10; 59 | layer1.showIndexes = @[@4, @1, @2, @3, @5, @6, @7, @9, @10, @12, @13, @14, @15]; 60 | layer1.frame = dashRect; 61 | [layer1 refresh]; 62 | 63 | YXYColorfulDashLayer *layer2 = [YXYColorfulDashLayer layer]; 64 | layer2.colors = @[(id)[UIColor yellowColor].CGColor, (id)[UIColor yellowColor].CGColor]; 65 | layer2.totalCount = 16; 66 | layer2.dashCornerRadius = 10; 67 | layer2.showIndexes = @[@0, @8, @11]; 68 | layer2.frame = dashRect; 69 | [layer2 refresh]; 70 | 71 | [self.view.layer addSublayer:layer1]; 72 | [self.view.layer addSublayer:layer2]; 73 | ``` 74 | 75 | ## 🔮 Example 76 | 77 | To run the example project, clone the repo and run YXYDashLayerSample target. 78 | 79 | ## 💰 Requirement 80 | 81 | - iOS 4.0+ 82 | - Xcode 9.0+ 83 | 84 | ## 📲 Installation 85 | 86 | ### CocoaPods 87 | 88 | [CocoaPods](http://cocoapods.org) is a dependency manager for Cocoa projects. You can install it with the following command: 89 | 90 | ```bash 91 | $ gem install cocoapods 92 | ``` 93 | 94 | To integrate YXYDashLayer into your Xcode project using CocoaPods, specify it in your `Podfile`: 95 | 96 | 97 | ``` 98 | source 'https://github.com/CocoaPods/Specs.git' 99 | platform :ios, '11.0' 100 | use_frameworks! 101 | target 'MyApp' do 102 | pod 'YXYDashLayer' 103 | end 104 | ``` 105 | 106 | You need replace "MyApp" with your project's name. 107 | 108 | Then, run the following command: 109 | 110 | ```bash 111 | $ pod install 112 | ``` 113 | 114 | ### Carthage 115 | 116 | [Carthage](https://github.com/Carthage/Carthage) is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. 117 | 118 | You can install Carthage with [Homebrew](http://brew.sh/) using the following command: 119 | 120 | ```bash 121 | $ brew update 122 | $ brew install carthage 123 | ``` 124 | 125 | To integrate YXYDashLayer into your Xcode project using Carthage, specify it in your `Cartfile`: 126 | 127 | ```ogdl 128 | github "yulingtianxia/YXYDashLayer" 129 | ``` 130 | 131 | Run `carthage update` to build the framework and drag the built `YXYDashLayerKit.framework` into your Xcode project. 132 | 133 | ### Manual 134 | 135 | Just drag the "Source" document folder into your project. 136 | 137 | ## ❤️ Contributed 138 | 139 | - If you **need help** or you'd like to **ask a general question**, open an issue. 140 | - If you **found a bug**, open an issue. 141 | - If you **have a feature request**, open an issue. 142 | - If you **want to contribute**, submit a pull request. 143 | 144 | ## 👨🏻‍💻 Author 145 | 146 | yulingtianxia, yulingtianxia@gmail.com 147 | 148 | ## 👮🏻 License 149 | 150 | YXYDashLayer is available under the MIT license. See the LICENSE file for more info. 151 | 152 | -------------------------------------------------------------------------------- /Source/YXYColorfulDashLayer.h: -------------------------------------------------------------------------------- 1 | // 2 | // YXYColorfulDashLayer.h 3 | // ProgressDashLayerSample 4 | // 5 | // Created by 杨萧玉 on 2018/4/8. 6 | // Copyright © 2018年 杨萧玉. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class YXYMaskDashLayer; 12 | 13 | @interface YXYColorfulDashLayer : CAGradientLayer 14 | 15 | /** 16 | 分段的间隙 17 | */ 18 | @property (nonatomic) CGFloat dashGap; 19 | /** 20 | 线宽 21 | */ 22 | @property (nonatomic) CGFloat dashWidth; 23 | /** 24 | 矩形的圆角半径 25 | */ 26 | @property (nonatomic) CGFloat dashCornerRadius; 27 | /** 28 | 分段总数 29 | */ 30 | @property (nonatomic) NSUInteger totalCount; 31 | /** 32 | 需要显示哪些分段的 index 33 | */ 34 | @property (nonatomic) NSArray *showIndexes; 35 | 36 | @property (nonatomic, readonly) YXYMaskDashLayer *maskLayer; 37 | 38 | /** 39 | 刷新整个Layer 40 | */ 41 | - (void)refresh; 42 | 43 | /** 44 | 仅刷新 Dash 的 totalCount、dashGap 和 showIndexes 45 | */ 46 | - (void)refreshDash; 47 | 48 | @end 49 | -------------------------------------------------------------------------------- /Source/YXYColorfulDashLayer.m: -------------------------------------------------------------------------------- 1 | // 2 | // YXYColorfulDashLayer.m 3 | // ProgressDashLayerSample 4 | // 5 | // Created by 杨萧玉 on 2018/4/8. 6 | // Copyright © 2018年 杨萧玉. All rights reserved. 7 | // 8 | 9 | #import "YXYColorfulDashLayer.h" 10 | #import "YXYMaskDashLayer.h" 11 | 12 | @interface YXYColorfulDashLayer () 13 | 14 | @property (nonatomic, readwrite) YXYMaskDashLayer *maskLayer; 15 | 16 | @end 17 | 18 | @implementation YXYColorfulDashLayer 19 | 20 | - (instancetype)init 21 | { 22 | self = [super init]; 23 | if (self) { 24 | _maskLayer = [YXYMaskDashLayer layer]; 25 | self.mask = _maskLayer; 26 | } 27 | return self; 28 | } 29 | 30 | #pragma mark - getter&setter 31 | 32 | - (void)setFrame:(CGRect)frame 33 | { 34 | [super setFrame:frame]; 35 | self.maskLayer.frame = self.bounds; 36 | } 37 | 38 | - (CGFloat)dashGap 39 | { 40 | return self.maskLayer.dashGap; 41 | } 42 | 43 | - (void)setDashGap:(CGFloat)dashGap 44 | { 45 | self.maskLayer.dashGap = dashGap; 46 | } 47 | 48 | - (CGFloat)dashWidth 49 | { 50 | return self.maskLayer.dashWidth; 51 | } 52 | 53 | - (void)setDashWidth:(CGFloat)dashWidth 54 | { 55 | self.maskLayer.dashWidth = dashWidth; 56 | } 57 | 58 | - (CGFloat)dashCornerRadius 59 | { 60 | return self.maskLayer.dashCornerRadius; 61 | } 62 | 63 | - (void)setDashCornerRadius:(CGFloat)dashCornerRadius 64 | { 65 | self.maskLayer.dashCornerRadius = dashCornerRadius; 66 | } 67 | 68 | - (NSUInteger)totalCount 69 | { 70 | return self.maskLayer.totalCount; 71 | } 72 | 73 | - (void)setTotalCount:(NSUInteger)totalCount 74 | { 75 | self.maskLayer.totalCount = totalCount; 76 | } 77 | 78 | - (NSArray *)showIndexes 79 | { 80 | return self.maskLayer.showIndexes; 81 | } 82 | 83 | - (void)setShowIndexes:(NSArray *)showIndexes 84 | { 85 | self.maskLayer.showIndexes = showIndexes; 86 | self.hidden = showIndexes.count == 0; 87 | } 88 | 89 | #pragma mark draw UI 90 | 91 | - (void)refresh 92 | { 93 | [self.maskLayer refresh]; 94 | } 95 | 96 | - (void)refreshDash 97 | { 98 | [self.maskLayer refreshDash]; 99 | } 100 | 101 | @end 102 | -------------------------------------------------------------------------------- /Source/YXYMaskDashLayer.h: -------------------------------------------------------------------------------- 1 | // 2 | // YXYMaskDashLayer.h 3 | // ProgressDashLayerSample 4 | // 5 | // Created by 杨萧玉 on 2018/4/20. 6 | // Copyright © 2018年 杨萧玉. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface YXYMaskDashLayer : CAShapeLayer 12 | 13 | /** 14 | 分段的间隙 15 | */ 16 | @property (nonatomic) CGFloat dashGap; 17 | /** 18 | 线宽 19 | */ 20 | @property (nonatomic) CGFloat dashWidth; 21 | /** 22 | 矩形的圆角半径 23 | */ 24 | @property (nonatomic) CGFloat dashCornerRadius; 25 | /** 26 | 分段总数 27 | */ 28 | @property (nonatomic) NSUInteger totalCount; 29 | /** 30 | 需要显示哪些分段的 index 31 | */ 32 | @property (nonatomic) NSArray *showIndexes; 33 | 34 | /** 35 | 刷新整个Layer 36 | */ 37 | - (void)refresh; 38 | 39 | /** 40 | 仅刷新 Dash 的 totalCount、dashGap 和 showIndexes 41 | */ 42 | - (void)refreshDash; 43 | 44 | @end 45 | -------------------------------------------------------------------------------- /Source/YXYMaskDashLayer.m: -------------------------------------------------------------------------------- 1 | // 2 | // YXYMaskDashLayer.m 3 | // ProgressDashLayerSample 4 | // 5 | // Created by 杨萧玉 on 2018/4/20. 6 | // Copyright © 2018年 杨萧玉. All rights reserved. 7 | // 8 | 9 | #import "YXYMaskDashLayer.h" 10 | 11 | @interface YXYMaskDashLayer () 12 | 13 | @property (nonatomic) CGFloat totalLength; 14 | @property (nonatomic) CGRect dashRect; 15 | @property (nonatomic) CGFloat realDashCornerRadius; 16 | 17 | @end 18 | 19 | @implementation YXYMaskDashLayer 20 | 21 | - (instancetype)init 22 | { 23 | self = [super init]; 24 | if (self) { 25 | _dashGap = 5; 26 | _dashCornerRadius = 5; 27 | _dashWidth = 3; 28 | self.lineCap = kCALineCapRound; 29 | self.fillColor = [UIColor clearColor].CGColor; 30 | self.strokeColor = [UIColor whiteColor].CGColor; 31 | } 32 | return self; 33 | } 34 | 35 | - (void)setTotalCount:(NSUInteger)totalCount 36 | { 37 | _totalCount = MAX(1, totalCount); 38 | } 39 | 40 | #pragma mark draw UI 41 | 42 | - (void)refresh 43 | { 44 | UIBezierPath *path = [UIBezierPath bezierPath]; 45 | self.dashRect = CGRectInset(self.bounds, self.dashWidth / 2, self.dashWidth / 2); 46 | CGFloat width = self.dashRect.size.width; 47 | CGFloat height = self.dashRect.size.height; 48 | self.realDashCornerRadius = MIN(self.dashCornerRadius - self.dashWidth / 2, width / 2); 49 | self.realDashCornerRadius = MAX(0, self.realDashCornerRadius); 50 | CGPoint center = CGPointMake(self.frame.size.width / 2, self.frame.size.height / 2); 51 | 52 | [path moveToPoint:CGPointMake(center.x - width / 2 + self.realDashCornerRadius, center.y - height / 2)]; 53 | 54 | [path addLineToPoint:CGPointMake(center.x + width / 2 - self.realDashCornerRadius, center.y - height / 2)]; 55 | 56 | [path addArcWithCenter:CGPointMake(center.x + width / 2 - self.realDashCornerRadius, center.y - height / 2 + self.realDashCornerRadius) radius:self.realDashCornerRadius startAngle:M_PI_2 * 3 endAngle:0 clockwise:YES]; 57 | 58 | [path addLineToPoint:CGPointMake(center.x + width / 2, center.y + height / 2 - self.realDashCornerRadius)]; 59 | 60 | [path addArcWithCenter:CGPointMake(center.x + width / 2 - self.realDashCornerRadius, center.y + height / 2 - self.realDashCornerRadius) radius:self.realDashCornerRadius startAngle:0 endAngle:M_PI_2 clockwise:YES]; 61 | 62 | [path addLineToPoint:CGPointMake(center.x - width / 2 + self.realDashCornerRadius, center.y + height / 2)]; 63 | 64 | [path addArcWithCenter:CGPointMake(center.x - width / 2 + self.realDashCornerRadius, center.y + height / 2 - self.realDashCornerRadius) radius:self.realDashCornerRadius startAngle:M_PI_2 endAngle:M_PI clockwise:YES]; 65 | 66 | [path addLineToPoint:CGPointMake(center.x - width / 2, center.y - height / 2 + self.realDashCornerRadius)]; 67 | 68 | [path addArcWithCenter:CGPointMake(center.x - width / 2 + self.realDashCornerRadius, center.y - height / 2 + self.realDashCornerRadius) radius:self.realDashCornerRadius startAngle:M_PI endAngle:M_PI_2 * 3 clockwise:YES]; 69 | 70 | self.totalLength = (width + height) * 2 - self.realDashCornerRadius * 8 + M_PI * self.realDashCornerRadius * 2; 71 | 72 | self.lineWidth = self.dashWidth; 73 | 74 | self.path = path.CGPath; 75 | 76 | [self refreshDash]; 77 | } 78 | 79 | - (void)refreshDash 80 | { 81 | [CATransaction begin]; 82 | [CATransaction setDisableActions:YES]; 83 | 84 | CGFloat realDashGap = (self.totalCount == 1) ? 0 : self.dashGap + self.dashWidth; 85 | NSUInteger realTotalCount = self.totalCount; 86 | CGFloat pieceLength = self.totalLength / self.totalCount - realDashGap; 87 | if (pieceLength < 0) { 88 | pieceLength = 0; 89 | realTotalCount = self.totalLength / realDashGap; 90 | pieceLength = self.totalLength / realTotalCount - realDashGap; 91 | NSLog(@"Can't show! Reduce total count or dash gap! Real Total Count: %lu, Real Dash Gap:%ff", (unsigned long)realTotalCount, realDashGap); 92 | } 93 | self.lineDashPhase = - (self.dashRect.size.width / 2 - self.realDashCornerRadius + realDashGap / 2); 94 | 95 | NSMutableArray *dashPattern = [NSMutableArray arrayWithCapacity:2 * realTotalCount]; 96 | NSInteger needsMovePhaseCount = 0; 97 | for (int i = 0; i < realTotalCount; i ++) { 98 | if ([self.showIndexes containsObject:@(i)]) { 99 | [dashPattern addObject:@(pieceLength)]; 100 | [dashPattern addObject:@(realDashGap)]; 101 | } 102 | else { 103 | if (dashPattern.count > 0) { 104 | dashPattern[dashPattern.count - 1] = @(dashPattern[dashPattern.count - 1].doubleValue + pieceLength + realDashGap); 105 | } 106 | else { 107 | self.lineDashPhase -= (pieceLength + realDashGap); 108 | needsMovePhaseCount ++; 109 | } 110 | } 111 | } 112 | if (needsMovePhaseCount > 0 && dashPattern.count > 0) { 113 | dashPattern[dashPattern.count - 1] = @(dashPattern[dashPattern.count - 1].doubleValue + (pieceLength + realDashGap) * needsMovePhaseCount); 114 | } 115 | 116 | if (self.showIndexes.count > 0) { 117 | self.lineDashPattern = dashPattern; 118 | } 119 | 120 | [CATransaction commit]; 121 | } 122 | 123 | @end 124 | -------------------------------------------------------------------------------- /Source/YXYProgressDashLayer.h: -------------------------------------------------------------------------------- 1 | // 2 | // YXYProgressDashLayer.h 3 | // ProgressDashLayerSample 4 | // 5 | // Created by 杨萧玉 on 2018/4/11. 6 | // Copyright © 2018年 杨萧玉. All rights reserved. 7 | // 8 | 9 | #import "YXYColorfulDashLayer.h" 10 | 11 | @class YXYColorfulDashLayer; 12 | 13 | @interface YXYProgressDashLayer : CALayer 14 | 15 | /** 16 | 分段的间隙 17 | */ 18 | @property (nonatomic) CGFloat dashGap; 19 | /** 20 | 线宽 21 | */ 22 | @property (nonatomic) CGFloat dashWidth; 23 | /** 24 | 矩形的圆角半径 25 | */ 26 | @property (nonatomic) CGFloat dashCornerRadius; 27 | /** 28 | 分段总数 29 | */ 30 | @property (nonatomic) NSUInteger totalCount; 31 | /** 32 | 进度段数 33 | */ 34 | @property (nonatomic) NSUInteger progress; 35 | /** 36 | 底层 Layer,可以自定义渐变颜色 37 | */ 38 | @property (nonatomic, readonly) YXYColorfulDashLayer *underLayer; 39 | /** 40 | 进度条颜色 41 | */ 42 | @property (nonatomic) UIColor *progressColor; 43 | 44 | 45 | /** 46 | 刷新整个Layer 47 | */ 48 | - (void)refresh; 49 | 50 | /** 51 | 仅刷新 Dash 的 totalCount、dashGap 和 progress 52 | */ 53 | - (void)refreshProgress; 54 | 55 | @end 56 | -------------------------------------------------------------------------------- /Source/YXYProgressDashLayer.m: -------------------------------------------------------------------------------- 1 | // 2 | // YXYProgressDashLayer.m 3 | // ProgressDashLayerSample 4 | // 5 | // Created by 杨萧玉 on 2018/4/11. 6 | // Copyright © 2018年 杨萧玉. All rights reserved. 7 | // 8 | 9 | #import "YXYProgressDashLayer.h" 10 | #import "YXYColorfulDashLayer.h" 11 | 12 | @interface YXYProgressDashLayer () 13 | 14 | @property (nonatomic, readwrite) YXYColorfulDashLayer *underLayer; 15 | @property (nonatomic) YXYColorfulDashLayer *progressLayer; 16 | 17 | @end 18 | 19 | @implementation YXYProgressDashLayer 20 | 21 | - (instancetype)init 22 | { 23 | self = [super init]; 24 | if (self) { 25 | 26 | self.underLayer = [YXYColorfulDashLayer layer]; 27 | self.progressLayer = [YXYColorfulDashLayer layer]; 28 | 29 | self.dashCornerRadius = 5; 30 | 31 | self.dashGap = 5; 32 | 33 | self.dashWidth = 3; 34 | 35 | self.totalCount = 10; 36 | 37 | self.progress = 1; 38 | 39 | [self addSublayer:self.underLayer]; 40 | [self addSublayer:self.progressLayer]; 41 | } 42 | return self; 43 | } 44 | 45 | - (void)setFrame:(CGRect)frame 46 | { 47 | [super setFrame:frame]; 48 | self.underLayer.frame = self.bounds; 49 | self.progressLayer.frame = self.bounds; 50 | } 51 | 52 | - (void)setProgressColor:(UIColor *)progressColor 53 | { 54 | _progressColor = progressColor; 55 | self.progressLayer.colors = @[(id)self.progressColor.CGColor, (id)self.progressColor.CGColor]; 56 | } 57 | 58 | - (void)setDashCornerRadius:(CGFloat)dashCornerRadius 59 | { 60 | _dashCornerRadius = dashCornerRadius; 61 | self.underLayer.dashCornerRadius = dashCornerRadius; 62 | self.progressLayer.dashCornerRadius = dashCornerRadius; 63 | } 64 | 65 | - (void)setDashGap:(CGFloat)dashGap 66 | { 67 | _dashGap = dashGap; 68 | self.underLayer.dashGap = self.dashGap; 69 | self.progressLayer.dashGap = self.dashGap; 70 | } 71 | 72 | - (void)setDashWidth:(CGFloat)dashWidth 73 | { 74 | _dashWidth = dashWidth; 75 | self.underLayer.dashWidth = dashWidth; 76 | self.progressLayer.dashWidth = dashWidth; 77 | } 78 | 79 | - (void)setTotalCount:(NSUInteger)totalCount 80 | { 81 | _totalCount = totalCount; 82 | self.underLayer.totalCount = totalCount; 83 | self.progressLayer.totalCount = totalCount; 84 | self.underLayer.showIndexes = [self indexesOfRange:NSMakeRange(0, totalCount)]; 85 | } 86 | 87 | - (void)setProgress:(NSUInteger)progress 88 | { 89 | _progress = progress; 90 | self.progressLayer.showIndexes = [self indexesOfRange:NSMakeRange(0, progress)]; 91 | NSUInteger underLayerLength = 0; 92 | if (progress <= self.totalCount) { 93 | underLayerLength = self.totalCount - progress; 94 | } 95 | self.underLayer.showIndexes = [self indexesOfRange:NSMakeRange(progress, underLayerLength)]; 96 | } 97 | 98 | - (NSArray *)indexesOfRange:(NSRange)range 99 | { 100 | NSMutableArray *array = [NSMutableArray arrayWithCapacity:range.length]; 101 | for (NSUInteger i = range.location; i < range.location + range.length; i ++) { 102 | [array addObject:@(i)]; 103 | } 104 | return array; 105 | } 106 | 107 | - (void)refresh 108 | { 109 | [self.underLayer refresh]; 110 | [self.progressLayer refresh]; 111 | } 112 | 113 | - (void)refreshProgress 114 | { 115 | [self.underLayer refreshDash]; 116 | [self.progressLayer refreshDash]; 117 | } 118 | 119 | @end 120 | -------------------------------------------------------------------------------- /YXYDashLayer.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "YXYDashLayer" 3 | s.version = "1.0.0" 4 | s.summary = "Just a dash rounded rect layer." 5 | s.description = <<-DESC 6 | It's ugly. Yeah! 7 | DESC 8 | s.homepage = "https://github.com/yulingtianxia/YXYDashLayer" 9 | 10 | s.license = { :type => 'MIT', :file => 'LICENSE' } 11 | s.author = { "YangXiaoyu" => "yulingtianxia@gmail.com" } 12 | s.social_media_url = 'https://twitter.com/yulingtianxia' 13 | s.source = { :git => "https://github.com/yulingtianxia/YXYDashLayer.git", :tag => s.version.to_s } 14 | 15 | s.ios.deployment_target = "4.0" 16 | s.tvos.deployment_target = "9.0" 17 | s.requires_arc = true 18 | 19 | s.source_files = "Source/*.{h,m}" 20 | s.public_header_files = "Source/YXYColorfulDashLayer.h", "Source/YXYMaskDashLayer.h", "Source/YXYProgressDashLayer.h" 21 | s.frameworks = 'Foundation', 'UIKit' 22 | 23 | end 24 | -------------------------------------------------------------------------------- /YXYDashLayerSample/YXYDashLayerKit/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | $(CURRENT_PROJECT_VERSION) 21 | NSPrincipalClass 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /YXYDashLayerSample/YXYDashLayerKit/YXYDashLayerKit.h: -------------------------------------------------------------------------------- 1 | // 2 | // YXYDashLayerKit.h 3 | // YXYDashLayerKit 4 | // 5 | // Created by 杨萧玉 on 2018/4/20. 6 | // Copyright © 2018年 杨萧玉. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for YXYDashLayerKit. 12 | FOUNDATION_EXPORT double YXYDashLayerKitVersionNumber; 13 | 14 | //! Project version string for YXYDashLayerKit. 15 | FOUNDATION_EXPORT const unsigned char YXYDashLayerKitVersionString[]; 16 | 17 | #import 18 | #import 19 | #import 20 | 21 | -------------------------------------------------------------------------------- /YXYDashLayerSample/YXYDashLayerSample.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 50; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | A4359764208A175E0056CFCF /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = A4359763208A175E0056CFCF /* AppDelegate.m */; }; 11 | A4359767208A175E0056CFCF /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = A4359766208A175E0056CFCF /* ViewController.m */; }; 12 | A435976A208A175E0056CFCF /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A4359768208A175E0056CFCF /* Main.storyboard */; }; 13 | A435976C208A175F0056CFCF /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A435976B208A175F0056CFCF /* Assets.xcassets */; }; 14 | A435976F208A175F0056CFCF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A435976D208A175F0056CFCF /* LaunchScreen.storyboard */; }; 15 | A4359772208A175F0056CFCF /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = A4359771208A175F0056CFCF /* main.m */; }; 16 | A435977F208A17670056CFCF /* YXYColorfulDashLayer.m in Sources */ = {isa = PBXBuildFile; fileRef = A435977A208A17670056CFCF /* YXYColorfulDashLayer.m */; }; 17 | A4359780208A17670056CFCF /* YXYMaskDashLayer.m in Sources */ = {isa = PBXBuildFile; fileRef = A435977C208A17670056CFCF /* YXYMaskDashLayer.m */; }; 18 | A4359781208A17670056CFCF /* YXYProgressDashLayer.m in Sources */ = {isa = PBXBuildFile; fileRef = A435977E208A17670056CFCF /* YXYProgressDashLayer.m */; }; 19 | A435978B208A25D30056CFCF /* YXYDashLayerKit.h in Headers */ = {isa = PBXBuildFile; fileRef = A4359789208A25D30056CFCF /* YXYDashLayerKit.h */; settings = {ATTRIBUTES = (Public, ); }; }; 20 | A435978E208A25D30056CFCF /* YXYDashLayerKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A4359787208A25D30056CFCF /* YXYDashLayerKit.framework */; }; 21 | A435978F208A25D30056CFCF /* YXYDashLayerKit.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = A4359787208A25D30056CFCF /* YXYDashLayerKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 22 | A4359794208A25E40056CFCF /* YXYMaskDashLayer.m in Sources */ = {isa = PBXBuildFile; fileRef = A435977C208A17670056CFCF /* YXYMaskDashLayer.m */; }; 23 | A4359795208A25E70056CFCF /* YXYColorfulDashLayer.m in Sources */ = {isa = PBXBuildFile; fileRef = A435977A208A17670056CFCF /* YXYColorfulDashLayer.m */; }; 24 | A4359796208A25EA0056CFCF /* YXYProgressDashLayer.m in Sources */ = {isa = PBXBuildFile; fileRef = A435977E208A17670056CFCF /* YXYProgressDashLayer.m */; }; 25 | /* End PBXBuildFile section */ 26 | 27 | /* Begin PBXContainerItemProxy section */ 28 | A435978C208A25D30056CFCF /* PBXContainerItemProxy */ = { 29 | isa = PBXContainerItemProxy; 30 | containerPortal = A4359757208A175E0056CFCF /* Project object */; 31 | proxyType = 1; 32 | remoteGlobalIDString = A4359786208A25D30056CFCF; 33 | remoteInfo = YXYDashLayerKit; 34 | }; 35 | /* End PBXContainerItemProxy section */ 36 | 37 | /* Begin PBXCopyFilesBuildPhase section */ 38 | A4359793208A25D30056CFCF /* Embed Frameworks */ = { 39 | isa = PBXCopyFilesBuildPhase; 40 | buildActionMask = 2147483647; 41 | dstPath = ""; 42 | dstSubfolderSpec = 10; 43 | files = ( 44 | A435978F208A25D30056CFCF /* YXYDashLayerKit.framework in Embed Frameworks */, 45 | ); 46 | name = "Embed Frameworks"; 47 | runOnlyForDeploymentPostprocessing = 0; 48 | }; 49 | /* End PBXCopyFilesBuildPhase section */ 50 | 51 | /* Begin PBXFileReference section */ 52 | A435975F208A175E0056CFCF /* YXYDashLayerSample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = YXYDashLayerSample.app; sourceTree = BUILT_PRODUCTS_DIR; }; 53 | A4359762208A175E0056CFCF /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 54 | A4359763208A175E0056CFCF /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 55 | A4359765208A175E0056CFCF /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 56 | A4359766208A175E0056CFCF /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 57 | A4359769208A175E0056CFCF /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 58 | A435976B208A175F0056CFCF /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 59 | A435976E208A175F0056CFCF /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 60 | A4359770208A175F0056CFCF /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 61 | A4359771208A175F0056CFCF /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 62 | A4359779208A17670056CFCF /* YXYColorfulDashLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YXYColorfulDashLayer.h; sourceTree = ""; }; 63 | A435977A208A17670056CFCF /* YXYColorfulDashLayer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = YXYColorfulDashLayer.m; sourceTree = ""; }; 64 | A435977B208A17670056CFCF /* YXYMaskDashLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YXYMaskDashLayer.h; sourceTree = ""; }; 65 | A435977C208A17670056CFCF /* YXYMaskDashLayer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = YXYMaskDashLayer.m; sourceTree = ""; }; 66 | A435977D208A17670056CFCF /* YXYProgressDashLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YXYProgressDashLayer.h; sourceTree = ""; }; 67 | A435977E208A17670056CFCF /* YXYProgressDashLayer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = YXYProgressDashLayer.m; sourceTree = ""; }; 68 | A4359787208A25D30056CFCF /* YXYDashLayerKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = YXYDashLayerKit.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 69 | A4359789208A25D30056CFCF /* YXYDashLayerKit.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = YXYDashLayerKit.h; sourceTree = ""; }; 70 | A435978A208A25D30056CFCF /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 71 | /* End PBXFileReference section */ 72 | 73 | /* Begin PBXFrameworksBuildPhase section */ 74 | A435975C208A175E0056CFCF /* Frameworks */ = { 75 | isa = PBXFrameworksBuildPhase; 76 | buildActionMask = 2147483647; 77 | files = ( 78 | A435978E208A25D30056CFCF /* YXYDashLayerKit.framework in Frameworks */, 79 | ); 80 | runOnlyForDeploymentPostprocessing = 0; 81 | }; 82 | A4359783208A25D30056CFCF /* Frameworks */ = { 83 | isa = PBXFrameworksBuildPhase; 84 | buildActionMask = 2147483647; 85 | files = ( 86 | ); 87 | runOnlyForDeploymentPostprocessing = 0; 88 | }; 89 | /* End PBXFrameworksBuildPhase section */ 90 | 91 | /* Begin PBXGroup section */ 92 | A4359756208A175E0056CFCF = { 93 | isa = PBXGroup; 94 | children = ( 95 | A4359778208A17670056CFCF /* Source */, 96 | A4359761208A175E0056CFCF /* YXYDashLayerSample */, 97 | A4359788208A25D30056CFCF /* YXYDashLayerKit */, 98 | A4359760208A175E0056CFCF /* Products */, 99 | ); 100 | sourceTree = ""; 101 | }; 102 | A4359760208A175E0056CFCF /* Products */ = { 103 | isa = PBXGroup; 104 | children = ( 105 | A435975F208A175E0056CFCF /* YXYDashLayerSample.app */, 106 | A4359787208A25D30056CFCF /* YXYDashLayerKit.framework */, 107 | ); 108 | name = Products; 109 | sourceTree = ""; 110 | }; 111 | A4359761208A175E0056CFCF /* YXYDashLayerSample */ = { 112 | isa = PBXGroup; 113 | children = ( 114 | A4359762208A175E0056CFCF /* AppDelegate.h */, 115 | A4359763208A175E0056CFCF /* AppDelegate.m */, 116 | A4359765208A175E0056CFCF /* ViewController.h */, 117 | A4359766208A175E0056CFCF /* ViewController.m */, 118 | A4359768208A175E0056CFCF /* Main.storyboard */, 119 | A435976B208A175F0056CFCF /* Assets.xcassets */, 120 | A435976D208A175F0056CFCF /* LaunchScreen.storyboard */, 121 | A4359770208A175F0056CFCF /* Info.plist */, 122 | A4359771208A175F0056CFCF /* main.m */, 123 | ); 124 | path = YXYDashLayerSample; 125 | sourceTree = ""; 126 | }; 127 | A4359778208A17670056CFCF /* Source */ = { 128 | isa = PBXGroup; 129 | children = ( 130 | A435977B208A17670056CFCF /* YXYMaskDashLayer.h */, 131 | A435977C208A17670056CFCF /* YXYMaskDashLayer.m */, 132 | A4359779208A17670056CFCF /* YXYColorfulDashLayer.h */, 133 | A435977A208A17670056CFCF /* YXYColorfulDashLayer.m */, 134 | A435977D208A17670056CFCF /* YXYProgressDashLayer.h */, 135 | A435977E208A17670056CFCF /* YXYProgressDashLayer.m */, 136 | ); 137 | name = Source; 138 | path = ../Source; 139 | sourceTree = ""; 140 | }; 141 | A4359788208A25D30056CFCF /* YXYDashLayerKit */ = { 142 | isa = PBXGroup; 143 | children = ( 144 | A4359789208A25D30056CFCF /* YXYDashLayerKit.h */, 145 | A435978A208A25D30056CFCF /* Info.plist */, 146 | ); 147 | path = YXYDashLayerKit; 148 | sourceTree = ""; 149 | }; 150 | /* End PBXGroup section */ 151 | 152 | /* Begin PBXHeadersBuildPhase section */ 153 | A4359784208A25D30056CFCF /* Headers */ = { 154 | isa = PBXHeadersBuildPhase; 155 | buildActionMask = 2147483647; 156 | files = ( 157 | A435978B208A25D30056CFCF /* YXYDashLayerKit.h in Headers */, 158 | ); 159 | runOnlyForDeploymentPostprocessing = 0; 160 | }; 161 | /* End PBXHeadersBuildPhase section */ 162 | 163 | /* Begin PBXNativeTarget section */ 164 | A435975E208A175E0056CFCF /* YXYDashLayerSample */ = { 165 | isa = PBXNativeTarget; 166 | buildConfigurationList = A4359775208A175F0056CFCF /* Build configuration list for PBXNativeTarget "YXYDashLayerSample" */; 167 | buildPhases = ( 168 | A435975B208A175E0056CFCF /* Sources */, 169 | A435975C208A175E0056CFCF /* Frameworks */, 170 | A435975D208A175E0056CFCF /* Resources */, 171 | A4359793208A25D30056CFCF /* Embed Frameworks */, 172 | ); 173 | buildRules = ( 174 | ); 175 | dependencies = ( 176 | A435978D208A25D30056CFCF /* PBXTargetDependency */, 177 | ); 178 | name = YXYDashLayerSample; 179 | productName = YXYDashLayerSample; 180 | productReference = A435975F208A175E0056CFCF /* YXYDashLayerSample.app */; 181 | productType = "com.apple.product-type.application"; 182 | }; 183 | A4359786208A25D30056CFCF /* YXYDashLayerKit */ = { 184 | isa = PBXNativeTarget; 185 | buildConfigurationList = A4359790208A25D30056CFCF /* Build configuration list for PBXNativeTarget "YXYDashLayerKit" */; 186 | buildPhases = ( 187 | A4359782208A25D30056CFCF /* Sources */, 188 | A4359783208A25D30056CFCF /* Frameworks */, 189 | A4359784208A25D30056CFCF /* Headers */, 190 | A4359785208A25D30056CFCF /* Resources */, 191 | ); 192 | buildRules = ( 193 | ); 194 | dependencies = ( 195 | ); 196 | name = YXYDashLayerKit; 197 | productName = YXYDashLayerKit; 198 | productReference = A4359787208A25D30056CFCF /* YXYDashLayerKit.framework */; 199 | productType = "com.apple.product-type.framework"; 200 | }; 201 | /* End PBXNativeTarget section */ 202 | 203 | /* Begin PBXProject section */ 204 | A4359757208A175E0056CFCF /* Project object */ = { 205 | isa = PBXProject; 206 | attributes = { 207 | LastUpgradeCheck = 0930; 208 | ORGANIZATIONNAME = "杨萧玉"; 209 | TargetAttributes = { 210 | A435975E208A175E0056CFCF = { 211 | CreatedOnToolsVersion = 9.3; 212 | }; 213 | A4359786208A25D30056CFCF = { 214 | CreatedOnToolsVersion = 9.3; 215 | }; 216 | }; 217 | }; 218 | buildConfigurationList = A435975A208A175E0056CFCF /* Build configuration list for PBXProject "YXYDashLayerSample" */; 219 | compatibilityVersion = "Xcode 9.3"; 220 | developmentRegion = en; 221 | hasScannedForEncodings = 0; 222 | knownRegions = ( 223 | en, 224 | Base, 225 | ); 226 | mainGroup = A4359756208A175E0056CFCF; 227 | productRefGroup = A4359760208A175E0056CFCF /* Products */; 228 | projectDirPath = ""; 229 | projectRoot = ""; 230 | targets = ( 231 | A435975E208A175E0056CFCF /* YXYDashLayerSample */, 232 | A4359786208A25D30056CFCF /* YXYDashLayerKit */, 233 | ); 234 | }; 235 | /* End PBXProject section */ 236 | 237 | /* Begin PBXResourcesBuildPhase section */ 238 | A435975D208A175E0056CFCF /* Resources */ = { 239 | isa = PBXResourcesBuildPhase; 240 | buildActionMask = 2147483647; 241 | files = ( 242 | A435976F208A175F0056CFCF /* LaunchScreen.storyboard in Resources */, 243 | A435976C208A175F0056CFCF /* Assets.xcassets in Resources */, 244 | A435976A208A175E0056CFCF /* Main.storyboard in Resources */, 245 | ); 246 | runOnlyForDeploymentPostprocessing = 0; 247 | }; 248 | A4359785208A25D30056CFCF /* Resources */ = { 249 | isa = PBXResourcesBuildPhase; 250 | buildActionMask = 2147483647; 251 | files = ( 252 | ); 253 | runOnlyForDeploymentPostprocessing = 0; 254 | }; 255 | /* End PBXResourcesBuildPhase section */ 256 | 257 | /* Begin PBXSourcesBuildPhase section */ 258 | A435975B208A175E0056CFCF /* Sources */ = { 259 | isa = PBXSourcesBuildPhase; 260 | buildActionMask = 2147483647; 261 | files = ( 262 | A4359780208A17670056CFCF /* YXYMaskDashLayer.m in Sources */, 263 | A4359767208A175E0056CFCF /* ViewController.m in Sources */, 264 | A4359772208A175F0056CFCF /* main.m in Sources */, 265 | A435977F208A17670056CFCF /* YXYColorfulDashLayer.m in Sources */, 266 | A4359764208A175E0056CFCF /* AppDelegate.m in Sources */, 267 | A4359781208A17670056CFCF /* YXYProgressDashLayer.m in Sources */, 268 | ); 269 | runOnlyForDeploymentPostprocessing = 0; 270 | }; 271 | A4359782208A25D30056CFCF /* Sources */ = { 272 | isa = PBXSourcesBuildPhase; 273 | buildActionMask = 2147483647; 274 | files = ( 275 | A4359795208A25E70056CFCF /* YXYColorfulDashLayer.m in Sources */, 276 | A4359794208A25E40056CFCF /* YXYMaskDashLayer.m in Sources */, 277 | A4359796208A25EA0056CFCF /* YXYProgressDashLayer.m in Sources */, 278 | ); 279 | runOnlyForDeploymentPostprocessing = 0; 280 | }; 281 | /* End PBXSourcesBuildPhase section */ 282 | 283 | /* Begin PBXTargetDependency section */ 284 | A435978D208A25D30056CFCF /* PBXTargetDependency */ = { 285 | isa = PBXTargetDependency; 286 | target = A4359786208A25D30056CFCF /* YXYDashLayerKit */; 287 | targetProxy = A435978C208A25D30056CFCF /* PBXContainerItemProxy */; 288 | }; 289 | /* End PBXTargetDependency section */ 290 | 291 | /* Begin PBXVariantGroup section */ 292 | A4359768208A175E0056CFCF /* Main.storyboard */ = { 293 | isa = PBXVariantGroup; 294 | children = ( 295 | A4359769208A175E0056CFCF /* Base */, 296 | ); 297 | name = Main.storyboard; 298 | sourceTree = ""; 299 | }; 300 | A435976D208A175F0056CFCF /* LaunchScreen.storyboard */ = { 301 | isa = PBXVariantGroup; 302 | children = ( 303 | A435976E208A175F0056CFCF /* Base */, 304 | ); 305 | name = LaunchScreen.storyboard; 306 | sourceTree = ""; 307 | }; 308 | /* End PBXVariantGroup section */ 309 | 310 | /* Begin XCBuildConfiguration section */ 311 | A4359773208A175F0056CFCF /* Debug */ = { 312 | isa = XCBuildConfiguration; 313 | buildSettings = { 314 | ALWAYS_SEARCH_USER_PATHS = NO; 315 | CLANG_ANALYZER_NONNULL = YES; 316 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 317 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 318 | CLANG_CXX_LIBRARY = "libc++"; 319 | CLANG_ENABLE_MODULES = YES; 320 | CLANG_ENABLE_OBJC_ARC = YES; 321 | CLANG_ENABLE_OBJC_WEAK = YES; 322 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 323 | CLANG_WARN_BOOL_CONVERSION = YES; 324 | CLANG_WARN_COMMA = YES; 325 | CLANG_WARN_CONSTANT_CONVERSION = YES; 326 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 327 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 328 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 329 | CLANG_WARN_EMPTY_BODY = YES; 330 | CLANG_WARN_ENUM_CONVERSION = YES; 331 | CLANG_WARN_INFINITE_RECURSION = YES; 332 | CLANG_WARN_INT_CONVERSION = YES; 333 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 334 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 335 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 336 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 337 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 338 | CLANG_WARN_STRICT_PROTOTYPES = YES; 339 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 340 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 341 | CLANG_WARN_UNREACHABLE_CODE = YES; 342 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 343 | CODE_SIGN_IDENTITY = "iPhone Developer"; 344 | COPY_PHASE_STRIP = NO; 345 | DEBUG_INFORMATION_FORMAT = dwarf; 346 | ENABLE_STRICT_OBJC_MSGSEND = YES; 347 | ENABLE_TESTABILITY = YES; 348 | GCC_C_LANGUAGE_STANDARD = gnu11; 349 | GCC_DYNAMIC_NO_PIC = NO; 350 | GCC_NO_COMMON_BLOCKS = YES; 351 | GCC_OPTIMIZATION_LEVEL = 0; 352 | GCC_PREPROCESSOR_DEFINITIONS = ( 353 | "DEBUG=1", 354 | "$(inherited)", 355 | ); 356 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 357 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 358 | GCC_WARN_UNDECLARED_SELECTOR = YES; 359 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 360 | GCC_WARN_UNUSED_FUNCTION = YES; 361 | GCC_WARN_UNUSED_VARIABLE = YES; 362 | IPHONEOS_DEPLOYMENT_TARGET = 11.3; 363 | MTL_ENABLE_DEBUG_INFO = YES; 364 | ONLY_ACTIVE_ARCH = YES; 365 | SDKROOT = iphoneos; 366 | }; 367 | name = Debug; 368 | }; 369 | A4359774208A175F0056CFCF /* Release */ = { 370 | isa = XCBuildConfiguration; 371 | buildSettings = { 372 | ALWAYS_SEARCH_USER_PATHS = NO; 373 | CLANG_ANALYZER_NONNULL = YES; 374 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 375 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; 376 | CLANG_CXX_LIBRARY = "libc++"; 377 | CLANG_ENABLE_MODULES = YES; 378 | CLANG_ENABLE_OBJC_ARC = YES; 379 | CLANG_ENABLE_OBJC_WEAK = YES; 380 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 381 | CLANG_WARN_BOOL_CONVERSION = YES; 382 | CLANG_WARN_COMMA = YES; 383 | CLANG_WARN_CONSTANT_CONVERSION = YES; 384 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 385 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 386 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 387 | CLANG_WARN_EMPTY_BODY = YES; 388 | CLANG_WARN_ENUM_CONVERSION = YES; 389 | CLANG_WARN_INFINITE_RECURSION = YES; 390 | CLANG_WARN_INT_CONVERSION = YES; 391 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 392 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 393 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 394 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 395 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 396 | CLANG_WARN_STRICT_PROTOTYPES = YES; 397 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 398 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 399 | CLANG_WARN_UNREACHABLE_CODE = YES; 400 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 401 | CODE_SIGN_IDENTITY = "iPhone Developer"; 402 | COPY_PHASE_STRIP = NO; 403 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 404 | ENABLE_NS_ASSERTIONS = NO; 405 | ENABLE_STRICT_OBJC_MSGSEND = YES; 406 | GCC_C_LANGUAGE_STANDARD = gnu11; 407 | GCC_NO_COMMON_BLOCKS = YES; 408 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 409 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 410 | GCC_WARN_UNDECLARED_SELECTOR = YES; 411 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 412 | GCC_WARN_UNUSED_FUNCTION = YES; 413 | GCC_WARN_UNUSED_VARIABLE = YES; 414 | IPHONEOS_DEPLOYMENT_TARGET = 11.3; 415 | MTL_ENABLE_DEBUG_INFO = NO; 416 | SDKROOT = iphoneos; 417 | VALIDATE_PRODUCT = YES; 418 | }; 419 | name = Release; 420 | }; 421 | A4359776208A175F0056CFCF /* Debug */ = { 422 | isa = XCBuildConfiguration; 423 | buildSettings = { 424 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 425 | CODE_SIGN_STYLE = Automatic; 426 | DEVELOPMENT_TEAM = D3RCVUP6VH; 427 | INFOPLIST_FILE = YXYDashLayerSample/Info.plist; 428 | LD_RUNPATH_SEARCH_PATHS = ( 429 | "$(inherited)", 430 | "@executable_path/Frameworks", 431 | ); 432 | PRODUCT_BUNDLE_IDENTIFIER = com.yulingtianxia.YXYDashLayerSample; 433 | PRODUCT_NAME = "$(TARGET_NAME)"; 434 | TARGETED_DEVICE_FAMILY = "1,2"; 435 | }; 436 | name = Debug; 437 | }; 438 | A4359777208A175F0056CFCF /* Release */ = { 439 | isa = XCBuildConfiguration; 440 | buildSettings = { 441 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 442 | CODE_SIGN_STYLE = Automatic; 443 | DEVELOPMENT_TEAM = D3RCVUP6VH; 444 | INFOPLIST_FILE = YXYDashLayerSample/Info.plist; 445 | LD_RUNPATH_SEARCH_PATHS = ( 446 | "$(inherited)", 447 | "@executable_path/Frameworks", 448 | ); 449 | PRODUCT_BUNDLE_IDENTIFIER = com.yulingtianxia.YXYDashLayerSample; 450 | PRODUCT_NAME = "$(TARGET_NAME)"; 451 | TARGETED_DEVICE_FAMILY = "1,2"; 452 | }; 453 | name = Release; 454 | }; 455 | A4359791208A25D30056CFCF /* Debug */ = { 456 | isa = XCBuildConfiguration; 457 | buildSettings = { 458 | CODE_SIGN_IDENTITY = ""; 459 | CODE_SIGN_STYLE = Automatic; 460 | CURRENT_PROJECT_VERSION = 1; 461 | DEFINES_MODULE = YES; 462 | DEVELOPMENT_TEAM = D3RCVUP6VH; 463 | DYLIB_COMPATIBILITY_VERSION = 1; 464 | DYLIB_CURRENT_VERSION = 1; 465 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 466 | INFOPLIST_FILE = YXYDashLayerKit/Info.plist; 467 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 468 | LD_RUNPATH_SEARCH_PATHS = ( 469 | "$(inherited)", 470 | "@executable_path/Frameworks", 471 | "@loader_path/Frameworks", 472 | ); 473 | PRODUCT_BUNDLE_IDENTIFIER = com.yulingtianxia.YXYDashLayerKit; 474 | PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; 475 | SKIP_INSTALL = YES; 476 | TARGETED_DEVICE_FAMILY = "1,2"; 477 | VERSIONING_SYSTEM = "apple-generic"; 478 | VERSION_INFO_PREFIX = ""; 479 | }; 480 | name = Debug; 481 | }; 482 | A4359792208A25D30056CFCF /* Release */ = { 483 | isa = XCBuildConfiguration; 484 | buildSettings = { 485 | CODE_SIGN_IDENTITY = ""; 486 | CODE_SIGN_STYLE = Automatic; 487 | CURRENT_PROJECT_VERSION = 1; 488 | DEFINES_MODULE = YES; 489 | DEVELOPMENT_TEAM = D3RCVUP6VH; 490 | DYLIB_COMPATIBILITY_VERSION = 1; 491 | DYLIB_CURRENT_VERSION = 1; 492 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 493 | INFOPLIST_FILE = YXYDashLayerKit/Info.plist; 494 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 495 | LD_RUNPATH_SEARCH_PATHS = ( 496 | "$(inherited)", 497 | "@executable_path/Frameworks", 498 | "@loader_path/Frameworks", 499 | ); 500 | PRODUCT_BUNDLE_IDENTIFIER = com.yulingtianxia.YXYDashLayerKit; 501 | PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)"; 502 | SKIP_INSTALL = YES; 503 | TARGETED_DEVICE_FAMILY = "1,2"; 504 | VERSIONING_SYSTEM = "apple-generic"; 505 | VERSION_INFO_PREFIX = ""; 506 | }; 507 | name = Release; 508 | }; 509 | /* End XCBuildConfiguration section */ 510 | 511 | /* Begin XCConfigurationList section */ 512 | A435975A208A175E0056CFCF /* Build configuration list for PBXProject "YXYDashLayerSample" */ = { 513 | isa = XCConfigurationList; 514 | buildConfigurations = ( 515 | A4359773208A175F0056CFCF /* Debug */, 516 | A4359774208A175F0056CFCF /* Release */, 517 | ); 518 | defaultConfigurationIsVisible = 0; 519 | defaultConfigurationName = Release; 520 | }; 521 | A4359775208A175F0056CFCF /* Build configuration list for PBXNativeTarget "YXYDashLayerSample" */ = { 522 | isa = XCConfigurationList; 523 | buildConfigurations = ( 524 | A4359776208A175F0056CFCF /* Debug */, 525 | A4359777208A175F0056CFCF /* Release */, 526 | ); 527 | defaultConfigurationIsVisible = 0; 528 | defaultConfigurationName = Release; 529 | }; 530 | A4359790208A25D30056CFCF /* Build configuration list for PBXNativeTarget "YXYDashLayerKit" */ = { 531 | isa = XCConfigurationList; 532 | buildConfigurations = ( 533 | A4359791208A25D30056CFCF /* Debug */, 534 | A4359792208A25D30056CFCF /* Release */, 535 | ); 536 | defaultConfigurationIsVisible = 0; 537 | defaultConfigurationName = Release; 538 | }; 539 | /* End XCConfigurationList section */ 540 | }; 541 | rootObject = A4359757208A175E0056CFCF /* Project object */; 542 | } 543 | -------------------------------------------------------------------------------- /YXYDashLayerSample/YXYDashLayerSample.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /YXYDashLayerSample/YXYDashLayerSample.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /YXYDashLayerSample/YXYDashLayerSample.xcodeproj/xcshareddata/xcschemes/YXYDashLayerKit.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 34 | 35 | 45 | 46 | 52 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 70 | 71 | 72 | 73 | 75 | 76 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /YXYDashLayerSample/YXYDashLayerSample.xcodeproj/xcshareddata/xcschemes/YXYDashLayerSample.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /YXYDashLayerSample/YXYDashLayerSample/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // YXYDashLayerSample 4 | // 5 | // Created by 杨萧玉 on 2018/4/20. 6 | // Copyright © 2018年 杨萧玉. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /YXYDashLayerSample/YXYDashLayerSample/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // YXYDashLayerSample 4 | // 5 | // Created by 杨萧玉 on 2018/4/20. 6 | // Copyright © 2018年 杨萧玉. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | 24 | - (void)applicationWillResignActive:(UIApplication *)application { 25 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 26 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 27 | } 28 | 29 | 30 | - (void)applicationDidEnterBackground:(UIApplication *)application { 31 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 32 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 33 | } 34 | 35 | 36 | - (void)applicationWillEnterForeground:(UIApplication *)application { 37 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 38 | } 39 | 40 | 41 | - (void)applicationDidBecomeActive:(UIApplication *)application { 42 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 43 | } 44 | 45 | 46 | - (void)applicationWillTerminate:(UIApplication *)application { 47 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 48 | } 49 | 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /YXYDashLayerSample/YXYDashLayerSample/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "20x20", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "20x20", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "29x29", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "29x29", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "idiom" : "ipad", 65 | "size" : "40x40", 66 | "scale" : "1x" 67 | }, 68 | { 69 | "idiom" : "ipad", 70 | "size" : "40x40", 71 | "scale" : "2x" 72 | }, 73 | { 74 | "idiom" : "ipad", 75 | "size" : "76x76", 76 | "scale" : "1x" 77 | }, 78 | { 79 | "idiom" : "ipad", 80 | "size" : "76x76", 81 | "scale" : "2x" 82 | }, 83 | { 84 | "idiom" : "ipad", 85 | "size" : "83.5x83.5", 86 | "scale" : "2x" 87 | }, 88 | { 89 | "idiom" : "ios-marketing", 90 | "size" : "1024x1024", 91 | "scale" : "1x" 92 | } 93 | ], 94 | "info" : { 95 | "version" : 1, 96 | "author" : "xcode" 97 | } 98 | } -------------------------------------------------------------------------------- /YXYDashLayerSample/YXYDashLayerSample/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /YXYDashLayerSample/YXYDashLayerSample/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /YXYDashLayerSample/YXYDashLayerSample/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 28 | 35 | 42 | 49 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | -------------------------------------------------------------------------------- /YXYDashLayerSample/YXYDashLayerSample/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /YXYDashLayerSample/YXYDashLayerSample/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // YXYDashLayerSample 4 | // 5 | // Created by 杨萧玉 on 2018/4/20. 6 | // Copyright © 2018年 杨萧玉. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /YXYDashLayerSample/YXYDashLayerSample/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // YXYDashLayerSample 4 | // 5 | // Created by 杨萧玉 on 2018/4/20. 6 | // Copyright © 2018年 杨萧玉. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "YXYProgressDashLayer.h" 11 | 12 | @interface ViewController () 13 | 14 | @property (weak, nonatomic) IBOutlet UISlider *cornerRadiusSlider; 15 | @property (weak, nonatomic) IBOutlet UISlider *dashGapSlider; 16 | @property (weak, nonatomic) IBOutlet UISlider *dashWidthSlider; 17 | @property (weak, nonatomic) IBOutlet UISlider *totalCountSlider; 18 | @property (weak, nonatomic) IBOutlet UISlider *grayCountSlider; 19 | 20 | @property (nonatomic) YXYProgressDashLayer *progressDash; 21 | 22 | @end 23 | 24 | @implementation ViewController 25 | 26 | - (void)viewDidLoad { 27 | [super viewDidLoad]; 28 | 29 | self.progressDash = [YXYProgressDashLayer layer]; 30 | self.progressDash.underLayer.colors = @[(id)[UIColor blueColor].CGColor, (id)[UIColor greenColor].CGColor]; 31 | self.progressDash.progressColor = [UIColor grayColor]; 32 | 33 | CGFloat radius = self.cornerRadiusSlider.value; 34 | self.progressDash.dashCornerRadius = radius; 35 | 36 | CGFloat dashGap = self.dashGapSlider.value; 37 | self.progressDash.dashGap = dashGap; 38 | 39 | CGFloat dashWidth = self.dashWidthSlider.value; 40 | self.progressDash.dashWidth = dashWidth; 41 | 42 | NSInteger count = self.totalCountSlider.value; 43 | self.progressDash.totalCount = count; 44 | 45 | self.progressDash.progress = self.grayCountSlider.value; 46 | 47 | CGRect dashRect = CGRectMake((self.view.frame.size.width - 200) / 2, 50, 200, 300); 48 | self.progressDash.frame = dashRect; 49 | [self.progressDash refresh]; 50 | [self.view.layer addSublayer:self.progressDash]; 51 | } 52 | 53 | 54 | - (IBAction)cornerRadiusChanged:(UISlider *)sender { 55 | self.progressDash.dashCornerRadius = self.cornerRadiusSlider.value; 56 | [self.progressDash refresh]; 57 | } 58 | - (IBAction)dashGapChanged:(UISlider *)sender { 59 | self.progressDash.dashGap = self.dashGapSlider.value; 60 | [self.progressDash refreshProgress]; 61 | } 62 | - (IBAction)dashWidthChanged:(UISlider *)sender { 63 | self.progressDash.dashWidth = self.dashWidthSlider.value; 64 | [self.progressDash refresh]; 65 | } 66 | - (IBAction)totalCountChanged:(UISlider *)sender { 67 | NSInteger count = self.totalCountSlider.value; 68 | self.progressDash.totalCount = count; 69 | [self.progressDash refreshProgress]; 70 | } 71 | - (IBAction)grayCountChanged:(UISlider *)sender { 72 | self.progressDash.progress = self.grayCountSlider.value; 73 | [self.progressDash refreshProgress]; 74 | } 75 | 76 | @end 77 | -------------------------------------------------------------------------------- /YXYDashLayerSample/YXYDashLayerSample/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // YXYDashLayerSample 4 | // 5 | // Created by 杨萧玉 on 2018/4/20. 6 | // Copyright © 2018年 杨萧玉. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | --------------------------------------------------------------------------------