• Stars
    star
    175
  • Rank 216,817 (Top 5 %)
  • Language
    Objective-C
  • License
    MIT License
  • Created over 6 years ago
  • Updated over 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Colorful Rounded Rect Dash Border

Build Status Version Carthage compatible License Platform CocoaPods CocoaPods Twitter Follow

YXYDashLayer

YXYProgressDashLayer is composed of YXYColorfulDashLayer, which is masked by YXYMaskDashLayer. They can draw dash rounded rects.

YXYMaskDashLayer controls the dash path. YXYColorfulDashLayer is a subclass of CAGradientLayer, so it can draw colorful dash path. YXYProgressDashLayer uses two instances of YXYColorfulDashLayer.

📚 Article

Colorful Rounded Rect Dash Border

🐒 Usage

self.progressDash = [YXYProgressDashLayer layer];
self.progressDash.underLayer.colors = @[(id)[UIColor blueColor].CGColor, (id)[UIColor greenColor].CGColor];
self.progressDash.progressColor = [UIColor grayColor];

CGFloat radius = self.cornerRadiusSlider.value;
self.progressDash.dashCornerRadius = radius;

CGFloat dashGap = self.dashGapSlider.value;
self.progressDash.dashGap = dashGap;

CGFloat dashWidth = self.dashWidthSlider.value;
self.progressDash.dashWidth = dashWidth;

NSInteger count = self.totalCountSlider.value;
self.progressDash.totalCount = count;

self.progressDash.progress = self.grayCountSlider.value;

CGRect dashRect = CGRectMake((self.view.frame.size.width - 200) / 2, 50, 200, 300);
self.progressDash.frame = dashRect;
[self.progressDash refresh];
[self.view.layer addSublayer:self.progressDash];

For better performance, you can use refreshProgress after modifying totalCountdashGap and progress. NOTE: refresh must be called when frame, dashWidth or dashCornerRadius changes.

CGRect dashRect = CGRectMake((self.view.frame.size.width - 200) / 2, 50, 200, 300);
YXYColorfulDashLayer *layer1 = [YXYColorfulDashLayer layer];
layer1.colors = @[(id)[UIColor blueColor].CGColor, (id)[UIColor redColor].CGColor, (id)[UIColor greenColor].CGColor];
layer1.totalCount = 16;
layer1.dashCornerRadius = 10;
layer1.showIndexes = @[@4, @1, @2, @3, @5, @6, @7, @9, @10, @12, @13, @14, @15];
layer1.frame = dashRect;
[layer1 refresh];
    
YXYColorfulDashLayer *layer2 = [YXYColorfulDashLayer layer];
layer2.colors = @[(id)[UIColor yellowColor].CGColor, (id)[UIColor yellowColor].CGColor];
layer2.totalCount = 16;
layer2.dashCornerRadius = 10;
layer2.showIndexes = @[@0, @8, @11];
layer2.frame = dashRect;
[layer2 refresh];
    
[self.view.layer addSublayer:layer1];
[self.view.layer addSublayer:layer2];

🔮 Example

To run the example project, clone the repo and run YXYDashLayerSample target.

💰 Requirement

  • iOS 4.0+
  • Xcode 9.0+

📲 Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

To integrate YXYDashLayer into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '11.0'
use_frameworks!
target 'MyApp' do
	pod 'YXYDashLayer'
end

You need replace "MyApp" with your project's name.

Then, run the following command:

$ pod install

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

To integrate YXYDashLayer into your Xcode project using Carthage, specify it in your Cartfile:

github "yulingtianxia/YXYDashLayer"

Run carthage update to build the framework and drag the built YXYDashLayerKit.framework into your Xcode project.

Manual

Just drag the "Source" document folder into your project.

❤️ Contributed

  • If you need help or you'd like to ask a general question, open an issue.
  • If you found a bug, open an issue.
  • If you have a feature request, open an issue.
  • If you want to contribute, submit a pull request.

👨🏻‍💻 Author

yulingtianxia, [email protected]

👮🏻 License

YXYDashLayer is available under the MIT license. See the LICENSE file for more info.

More Repositories

1

FishChat

Hook WeChat.app on non-jailbroken devices.
1,118
star
2

TBActionSheet

A Custom&Powerful Action Sheet For iOS. 一个 ActionSheet 满足所有样式!超高自由度的可定制!
Objective-C
950
star
3

BlockHook

Hook Objective-C blocks. A powerful AOP tool.
C
836
star
4

MessageThrottle

A lightweight Objective-C message throttle and debounce library.
Objective-C
823
star
5

AppOrderFiles

The easiest way to generate order files for Mach-O using Clang. Improving App Performance.
Objective-C
652
star
6

pbxprojHelper

A macOS tool help you handling project.pbxproj files. Written in Swift 5!
Swift
484
star
7

TBUIAutoTest

Generating UI test label automatically for iOS.
Objective-C
349
star
8

FuckFakeGitHubStars

GitHub 虚假 Star 净网行动
Python
265
star
9

Core-ML-Sample

A Demo using Vision Framework building on Core ML Framework
Swift
218
star
10

SimilarImageHunter

Mac 上寻找相似内容的图片工具
Objective-C
172
star
11

HardChoice

有时候作抉择真的很痛苦,Swift写的生活类APP
Swift
92
star
12

Spiral

A Game Developed with Swift and SpriteKit
Swift
88
star
13

AudioEmotion

Recognize Audio Emotion.
Python
86
star
14

BlockTracker

Tracking block args of Objective-C method based on BlockHook
Objective-C
78
star
15

PhotoAssessment

Photo Assessment using Core ML and Metal.
Objective-C
72
star
16

ColorAtom

用SpriteKit写的关于正能量的小游戏
Objective-C
49
star
17

Algorithm-Experiment

Algorithm experiment code written by Swift
Swift
46
star
18

Self-Sizing-CollectionView-Demo

This is the Demo showed in http://yulingtianxia.com/blog/2014/08/17/New-in-Table-and-Collection-Views/
Swift
35
star
19

YXYNumberAnimationLabel

一个数字动画Label
Objective-C
33
star
20

TFSHelper

Mac 上自动捕获并打开 TFS 链接的小工具
Swift
32
star
21

WebViewImageClick

看美图必备
Objective-C
27
star
22

ClassWrittenInSwift

Something for Class written in Swift.
Objective-C++
18
star
23

ImageMask

iOS刮刮卡的实现
Objective-C
17
star
24

javaQQ

用java写的QQ客户端,简单地聊天和发送文件功能
Java
14
star
25

DirtyWords-for-Xcode

Highlight dirty words in Xcode.
Swift
11
star
26

HandGestureCNN

Trainning Inception v3 model with Keras, and predict with MPS on iOS.
Swift
10
star
27

ChangYou

畅游室内导航
Java
7
star
28

Blog-Hexo-Source

My Blog Source
JavaScript
5
star
29

yulingtianxia.github.io

我的技术博客
HTML
5
star
30

MyCDDemo

Core Data Demo
Objective-C
4
star
31

Linger

临哥让我做的内部使用的 Mac 平台简易日志分析工具,不知道起啥名字好,就叫 Linger 吧
Objective-C
3
star
32

Pebble-MoHa

Pebble Watchface +1s
C
2
star
33

FavoriteGirls

Machine Learning Demo
Python
2
star
34

MyFirstGame

无聊写的小游戏
Objective-C
1
star
35

LeetCode

记录LeetCode刷题
C++
1
star