├── .gitignore ├── LSLColorPikerDemo ├── ColorPickerClass │ ├── LSLHSBColorPickerView.h │ └── LSLHSBColorPickerView.m ├── GIF │ └── colorPickerView.gif ├── LICENSE ├── LSLColorPickerDemo.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata ├── LSLColorPickerView.podspec ├── LSLColorPikerDemo │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Assets.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ ├── Info.plist │ ├── ViewController.h │ ├── ViewController.m │ └── main.m ├── LSLColorPikerDemoTests │ ├── Info.plist │ └── LSLColorPikerDemoTests.m └── LSLColorPikerDemoUITests │ ├── Info.plist │ └── LSLColorPikerDemoUITests.m └── README.md /.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 | *.xcuserstate 23 | 24 | ## Obj-C/Swift specific 25 | *.hmap 26 | *.ipa 27 | *.dSYM.zip 28 | *.dSYM 29 | 30 | # CocoaPods 31 | # 32 | # We recommend against adding the Pods directory to your .gitignore. However 33 | # you should judge for yourself, the pros and cons are mentioned at: 34 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 35 | # 36 | # Pods/ 37 | 38 | # Carthage 39 | # 40 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 41 | # Carthage/Checkouts 42 | 43 | Carthage/Build 44 | 45 | # fastlane 46 | # 47 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 48 | # screenshots whenever they are needed. 49 | # For more information about the recommended setup visit: 50 | # https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md 51 | 52 | fastlane/report.xml 53 | fastlane/screenshots 54 | 55 | #Code Injection 56 | # 57 | # After new code Injection tools there's a generated folder /iOSInjectionProject 58 | # https://github.com/johnno1962/injectionforxcode 59 | 60 | iOSInjectionProject/ 61 | -------------------------------------------------------------------------------- /LSLColorPikerDemo/ColorPickerClass/LSLHSBColorPickerView.h: -------------------------------------------------------------------------------- 1 | // 2 | // LSLColorPickerView.h 3 | // LongshaoDream 4 | // 5 | // Created by Bruce Li on 16/4/17. 6 | // Copyright © 2016年 longshao. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface LSLHSBColorPickerView : UIView 12 | 13 | @property (nonatomic, strong) UIColor *preColor; 14 | 15 | - (void)saveSelectedColorsToArchiver; 16 | + (void)cleanSelectedColorsInArchiver; 17 | 18 | - (void)colorSelectedBlock:(void(^)(UIColor *color, BOOL isConfirm))colorSelectedBlock; 19 | 20 | @end 21 | -------------------------------------------------------------------------------- /LSLColorPikerDemo/ColorPickerClass/LSLHSBColorPickerView.m: -------------------------------------------------------------------------------- 1 | // 2 | // LSLColorPickerView.m 3 | // LongshaoDream 4 | // 5 | // Created by Bruce Li on 16/4/17. 6 | // Copyright © 2016年 longshao. All rights reserved. 7 | // 8 | 9 | #import "LSLHSBColorPickerView.h" 10 | 11 | CGFloat const kLSLColorPickerAnimationDuration = 1.0; 12 | CGFloat const kLSLColorPickerMenuAnimationDuration = 0.25; 13 | 14 | #pragma mark - LSLMenuWindow Implementation 15 | 16 | ///////////////////////////////////////////// 17 | /** LSLMenuWindow */ 18 | ///////////////////////////////////////////// 19 | 20 | @interface LSLMenuView : UIView 21 | @end 22 | 23 | @implementation LSLMenuView 24 | 25 | - (instancetype)initWithFrame:(CGRect)frame { 26 | if (self = [super initWithFrame:frame]) { 27 | self.backgroundColor = [UIColor clearColor]; 28 | } 29 | return self; 30 | } 31 | 32 | - (void)drawRect:(CGRect)rect { 33 | CGSize size = self.frame.size; 34 | float fw = size.width; 35 | float fh = size.height * 7 / 9; 36 | CGSize triangleSize = CGSizeMake(size.width, size.height - fh); 37 | 38 | [[UIColor clearColor] set]; 39 | UIRectFill([self bounds]); 40 | 41 | // draw rounded rectangle 42 | CGContextRef context = UIGraphicsGetCurrentContext(); 43 | CGContextMoveToPoint(context, fw, fh - 10); // right 44 | CGContextAddArcToPoint(context, fw, fh, fw - 5, fh , 10); // right bottom 45 | CGContextAddArcToPoint(context, 0 , fh, 0 , fh - 5, 10); // left bottom 46 | CGContextAddArcToPoint(context, 0 , 0 , fw - 5, 0 , 10); // left top 47 | CGContextAddArcToPoint(context, fw, 0 , fw , fh - 5, 10); // right top 48 | CGContextClosePath(context); 49 | [[UIColor colorWithWhite:0.1 alpha:0.9] setFill]; 50 | CGContextDrawPath(context, kCGPathFillStroke); 51 | 52 | // draw triangle 53 | CGContextBeginPath(context); 54 | CGContextMoveToPoint(context, triangleSize.width * 0.35, fh); 55 | CGContextAddLineToPoint(context, triangleSize.width * 0.50, CGRectGetMaxY(self.frame)); 56 | CGContextAddLineToPoint(context, triangleSize.width * 0.65, fh); 57 | CGContextClosePath(context); 58 | [[UIColor colorWithWhite:0.1 alpha:0.9] setFill]; 59 | CGContextDrawPath(context, kCGPathFillStroke); 60 | } 61 | 62 | @end 63 | 64 | @interface LSLMenuWindow : UIWindow 65 | 66 | @property (nonatomic, strong) UILabel *titleLabel; 67 | @property (nonatomic, strong) LSLMenuView *menuView; 68 | 69 | + (instancetype)shareMenuWindow; 70 | 71 | - (void)updateWithFrame:(CGRect)frame; 72 | 73 | + (void)animationToShowMenu; 74 | + (void)animationToHiddenMenu; 75 | 76 | @end 77 | 78 | @implementation LSLMenuWindow 79 | 80 | + (instancetype)shareMenuWindow { 81 | static LSLMenuWindow *menuWindow; 82 | static dispatch_once_t onceToken; 83 | dispatch_once(&onceToken, ^{ 84 | menuWindow = [[LSLMenuWindow alloc] initWithFrame:CGRectMake(0, 0, 70, 45)]; 85 | menuWindow.windowLevel = UIWindowLevelAlert; 86 | menuWindow.hidden = YES; 87 | [menuWindow makeKeyAndVisible]; 88 | }); 89 | return menuWindow; 90 | } 91 | 92 | - (instancetype)initWithFrame:(CGRect)frame { 93 | if (self = [super initWithFrame:frame]) { 94 | self.backgroundColor = [UIColor clearColor]; 95 | 96 | UIViewController *rootVC = [[UIViewController alloc] init]; 97 | rootVC.view.frame = self.bounds; 98 | rootVC.view.layer.anchorPoint = CGPointMake(0.5, 1.0); 99 | rootVC.view.backgroundColor = [UIColor clearColor]; 100 | 101 | _menuView = [[LSLMenuView alloc] init]; 102 | [rootVC.view addSubview:_menuView]; 103 | 104 | _titleLabel = [[UILabel alloc] init]; 105 | _titleLabel.textAlignment = NSTextAlignmentCenter; 106 | _titleLabel.font = [UIFont systemFontOfSize:14]; 107 | _titleLabel.textColor = [UIColor whiteColor]; 108 | [rootVC.view addSubview:_titleLabel]; 109 | 110 | self.rootViewController = rootVC; 111 | } 112 | return self; 113 | } 114 | 115 | - (void)layoutSubviews { 116 | [super layoutSubviews]; 117 | 118 | _menuView.frame = self.bounds; 119 | _titleLabel.frame = CGRectMake(0, 0, _menuView.frame.size.width, _menuView.frame.size.height * 7 / 9); 120 | } 121 | 122 | #pragma mark - getter 123 | 124 | - (CGRect)frame { 125 | return self.rootViewController.view.frame; 126 | } 127 | 128 | #pragma mark - 129 | 130 | - (void)updateWithFrame:(CGRect)frame { 131 | self.rootViewController.view.frame = frame; 132 | } 133 | 134 | + (void)animationToShowMenu { 135 | [LSLMenuWindow shareMenuWindow].hidden = NO; 136 | 137 | // animation to show 138 | CABasicAnimation *scaleAnimation = [CABasicAnimation animation]; 139 | scaleAnimation.keyPath = @"transform.scale"; 140 | scaleAnimation.duration = kLSLColorPickerMenuAnimationDuration; 141 | scaleAnimation.fromValue = @(0.0); 142 | scaleAnimation.toValue = @(1.0); 143 | scaleAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; 144 | scaleAnimation.fillMode = kCAFillModeForwards; 145 | scaleAnimation.removedOnCompletion = NO; 146 | [[LSLMenuWindow shareMenuWindow].rootViewController.view.layer addAnimation:scaleAnimation forKey:@"menuWindowScaleToShow"]; 147 | } 148 | 149 | + (void)animationToHiddenMenu { 150 | // animation to hidden 151 | CABasicAnimation *scaleAnimation = [CABasicAnimation animation]; 152 | scaleAnimation.keyPath = @"transform.scale"; 153 | scaleAnimation.duration = kLSLColorPickerMenuAnimationDuration; 154 | scaleAnimation.toValue = @(0.0); 155 | scaleAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; 156 | scaleAnimation.fillMode = kCAFillModeForwards; 157 | scaleAnimation.removedOnCompletion = NO; 158 | [[LSLMenuWindow shareMenuWindow].rootViewController.view.layer addAnimation:scaleAnimation forKey:@"menuWindowScaleToHidden"]; 159 | 160 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(kLSLColorPickerMenuAnimationDuration * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ 161 | [LSLMenuWindow shareMenuWindow].hidden = YES; 162 | }); 163 | } 164 | 165 | @end 166 | 167 | #pragma mark - LSLSlider Implementation 168 | 169 | ///////////////////////////////////////////// 170 | /** LSLSlider */ 171 | ///////////////////////////////////////////// 172 | 173 | typedef void (^SliderValueChangeBlock)(CGFloat value, BOOL confirm); 174 | 175 | @interface LSLSlider : UIView 176 | 177 | @property(nonatomic) CGFloat value; 178 | @property (nonatomic, strong) UIView *vittaView; 179 | @property (nonatomic, strong) UIButton *indicatorButton; 180 | 181 | - (void)changeValue:(CGFloat)value animation:(BOOL)isAnimation; 182 | - (void)sliderValueChangeBlock:(void(^)(CGFloat value, BOOL confirm))sliderValueChangeBlock; 183 | 184 | @end 185 | 186 | @interface LSLSlider () 187 | 188 | @property (nonatomic, assign) CGFloat minX; 189 | @property (nonatomic, assign) CGFloat maxX; 190 | 191 | @property (nonatomic, assign) CGFloat preX; 192 | 193 | @property (nonatomic, copy) SliderValueChangeBlock sliderValueChangeBlock; 194 | 195 | @end 196 | 197 | @implementation LSLSlider 198 | 199 | - (instancetype)initWithFrame:(CGRect)frame { 200 | if (self = [super initWithFrame:frame]) { 201 | _vittaView = [[UIView alloc] init]; 202 | _vittaView.layer.masksToBounds = YES; 203 | _vittaView.layer.borderColor = [UIColor colorWithWhite:0.8 alpha:1.0].CGColor; 204 | _vittaView.layer.borderWidth = 0.1; 205 | [self addSubview:_vittaView]; 206 | 207 | _indicatorButton = [[UIButton alloc] init]; 208 | _indicatorButton.backgroundColor = [UIColor whiteColor]; 209 | _indicatorButton.layer.borderWidth = 0.1; 210 | _indicatorButton.layer.borderColor = [UIColor colorWithWhite:0.80 alpha:1.0].CGColor; 211 | _indicatorButton.layer.shadowOffset = CGSizeMake(0, 3); 212 | _indicatorButton.layer.shadowRadius = 3; 213 | _indicatorButton.layer.shadowOpacity = 0.2; 214 | 215 | UIPanGestureRecognizer *panRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(changedIndicatorButtonPosition:)]; 216 | [_indicatorButton addGestureRecognizer:panRecognizer]; 217 | 218 | // animation to show or hidden the menu 219 | [_indicatorButton addTarget:self action:@selector(showMenuByButtonClick:) forControlEvents:UIControlEventTouchDown]; 220 | [_indicatorButton addTarget:self action:@selector(hiddenMenuByButtonClick:) forControlEvents:UIControlEventTouchUpInside]; 221 | 222 | [self addSubview:_indicatorButton]; 223 | } 224 | return self; 225 | } 226 | 227 | - (void)layoutSubviews { 228 | [super layoutSubviews]; 229 | 230 | CGPoint center = _indicatorButton.center; 231 | CGSize size = self.frame.size; 232 | CGFloat indicatorBtnWidth = size.height - 1; 233 | CGFloat vittaViewWidth = size.width - indicatorBtnWidth; 234 | _minX = indicatorBtnWidth * 0.5; 235 | _maxX = size.width - indicatorBtnWidth * 1.5; 236 | 237 | _vittaView.frame = CGRectMake(_minX, 4, vittaViewWidth, size.height - 8); 238 | _vittaView.layer.cornerRadius = _vittaView.frame.size.height * 0.5; 239 | 240 | _indicatorButton.frame = CGRectMake(_maxX, 0, indicatorBtnWidth, indicatorBtnWidth); 241 | _indicatorButton.layer.cornerRadius = indicatorBtnWidth * 0.5; 242 | if (!CGPointEqualToPoint(center, CGPointZero)) { 243 | _indicatorButton.center = center; 244 | } 245 | } 246 | 247 | #pragma mark - 248 | 249 | - (void)changedIndicatorButtonPosition:(UIPanGestureRecognizer *)recognizer { 250 | CGRect frame = self.indicatorButton.frame; 251 | self.preX = frame.origin.x; 252 | 253 | CGPoint currentPoint = [recognizer locationInView:self]; 254 | CGFloat moveX = currentPoint.x - self.preX; 255 | frame.origin.x += moveX; 256 | if (frame.origin.x < self.minX) { 257 | frame.origin.x = self.minX; 258 | }else if (frame.origin.x > self.maxX){ 259 | frame.origin.x = self.maxX; 260 | } 261 | self.indicatorButton.frame = frame; 262 | 263 | CGFloat actualOffsetX = frame.origin.x - self.minX; 264 | self.value = actualOffsetX / (self.vittaView.frame.size.width - 2 * self.minX); 265 | 266 | switch (recognizer.state) { 267 | case UIGestureRecognizerStateBegan:{ 268 | if ([LSLMenuWindow shareMenuWindow].hidden) { 269 | [self changeMenuFrameAndValue]; 270 | [LSLMenuWindow animationToShowMenu]; 271 | } 272 | break; 273 | } 274 | case UIGestureRecognizerStateChanged:{ 275 | if (frame.origin.x >= 0 && frame.origin.x <= self.vittaView.frame.size.width) { 276 | [self changeMenuFrameAndValue]; 277 | if (self.sliderValueChangeBlock) { 278 | self.sliderValueChangeBlock(self.value, NO); 279 | } 280 | } 281 | break; 282 | } 283 | case UIGestureRecognizerStateEnded: { 284 | if (frame.origin.x >= 0 && frame.origin.x <= self.vittaView.frame.size.width) { 285 | [self changeMenuFrameAndValue]; 286 | if (self.sliderValueChangeBlock) { 287 | self.sliderValueChangeBlock(self.value, YES); 288 | } 289 | } 290 | [LSLMenuWindow animationToHiddenMenu]; 291 | 292 | break; 293 | } 294 | default: { 295 | break; 296 | } 297 | } 298 | } 299 | 300 | - (void)changeValue:(CGFloat)value animation:(BOOL)isAnimation { 301 | if (isAnimation) { 302 | [self changePositionAnimationWithValue:value andDuration:kLSLColorPickerAnimationDuration]; 303 | }else{ 304 | [self changePositionAnimationWithValue:value andDuration:0.0]; 305 | } 306 | self.value = value; 307 | } 308 | 309 | - (void)changePositionAnimationWithValue:(CGFloat)value andDuration:(CGFloat)duration { 310 | CGSize size = self.indicatorButton.frame.size; 311 | CGFloat vittaViewWidth = self.vittaView.frame.size.width; 312 | CGFloat toX = value * vittaViewWidth; 313 | if (toX < self.minX) { 314 | toX = self.minX; 315 | } 316 | 317 | [UIView animateWithDuration:duration animations:^{ 318 | [self.indicatorButton setCenter:CGPointMake(toX, size.width * 0.5)]; 319 | }]; 320 | } 321 | 322 | #pragma mark - menu 323 | 324 | - (void)hiddenMenuByButtonClick:(UIButton *)button { 325 | [LSLMenuWindow animationToHiddenMenu]; 326 | } 327 | 328 | - (void)showMenuByButtonClick:(UIButton *)button { 329 | [self changeMenuFrameAndValue]; 330 | [LSLMenuWindow animationToShowMenu]; 331 | } 332 | 333 | - (void)changeMenuFrameAndValue { 334 | CGRect frame = self.indicatorButton.frame; 335 | CGRect menuFrame = [LSLMenuWindow shareMenuWindow].frame; 336 | CGPoint origin = [[LSLMenuWindow shareMenuWindow] convertPoint:self.indicatorButton.center fromView:self.indicatorButton.superview]; 337 | menuFrame.origin.x = origin.x - frame.size.width - 10; 338 | menuFrame.origin.y = origin.y - frame.size.height - 33; 339 | 340 | [[LSLMenuWindow shareMenuWindow] updateWithFrame:menuFrame]; 341 | [LSLMenuWindow shareMenuWindow].titleLabel.text = [NSString stringWithFormat:@"%.1f%@",self.value * 100, @"%"]; 342 | } 343 | 344 | #pragma mark - setter 345 | 346 | - (void)setValue:(CGFloat)value { 347 | if (value > 1.0) { 348 | value = 1.0; 349 | }else if (value < 0.0){ 350 | value = 0.0; 351 | } 352 | _value = value; 353 | } 354 | 355 | #pragma mark - block 356 | 357 | - (void)sliderValueChangeBlock:(void (^)(CGFloat, BOOL))sliderValueChangeBlock { 358 | if (sliderValueChangeBlock) { 359 | self.sliderValueChangeBlock = sliderValueChangeBlock; 360 | } 361 | } 362 | 363 | @end 364 | 365 | #pragma mark - LSLSemiCircleView Implementation 366 | 367 | ///////////////////////////////////////////// 368 | /** LSLSemiCircleView */ 369 | ///////////////////////////////////////////// 370 | 371 | @interface LSLSemiCircleView : UIView 372 | 373 | @property (nonatomic) BOOL onRight; 374 | 375 | @property (nonatomic, strong) UIColor *semiCircleColor; 376 | 377 | @end 378 | 379 | @implementation LSLSemiCircleView 380 | 381 | - (instancetype)initWithFrame:(CGRect)frame { 382 | if (self = [super initWithFrame:frame]) { 383 | _semiCircleColor = [UIColor redColor]; 384 | self.backgroundColor = [UIColor clearColor]; 385 | } 386 | return self; 387 | } 388 | 389 | - (void)setSemiCircleColor:(UIColor *)semiCircleColor { 390 | if (semiCircleColor) { 391 | _semiCircleColor = semiCircleColor; 392 | [self setNeedsDisplay]; 393 | } 394 | } 395 | 396 | - (void)setOnRight:(BOOL)onRight { 397 | _onRight = onRight; 398 | [self setNeedsDisplay]; 399 | } 400 | 401 | - (void)drawRect:(CGRect)rect 402 | { 403 | CGFloat width = self.frame.size.height * 0.5 - 1; 404 | CGContextRef context = UIGraphicsGetCurrentContext(); 405 | CGContextSetFillColorWithColor(context, self.semiCircleColor.CGColor); 406 | CGContextSetLineWidth(context, 0.0); 407 | if (self.onRight) { 408 | CGContextAddArc(context, width + 1, width + 1, width, 0 , M_PI * 2, 1); 409 | } else { 410 | CGContextAddArc(context, 0, width + 1, width, 0 , M_PI * 2, 0); 411 | } 412 | CGContextDrawPath(context, kCGPathFillStroke); 413 | } 414 | @end 415 | 416 | #pragma mark - LSLColorCicle Implementation 417 | 418 | /////////////////////////////////////// 419 | /** LSLColorCicle */ 420 | /////////////////////////////////////// 421 | 422 | @interface LSLColorCicle : UIView 423 | @end 424 | 425 | @implementation LSLColorCicle 426 | 427 | - (instancetype)initWithFrame:(CGRect)frame { 428 | if (self = [super initWithFrame:frame]) { 429 | self.backgroundColor = [UIColor whiteColor]; 430 | self.layer.cornerRadius = frame.size.width * 0.5; 431 | self.layer.masksToBounds = YES; 432 | } 433 | return self; 434 | } 435 | 436 | - (void)layoutSubviews { 437 | [super layoutSubviews]; 438 | self.layer.cornerRadius = self.frame.size.width * 0.5; 439 | } 440 | 441 | - (void)drawRect:(CGRect)rect 442 | { 443 | CGPoint center = CGPointMake(self.frame.size.width * 0.5, self.frame.size.height * 0.5); 444 | CGFloat radiur = self.frame.size.width; 445 | for (int hue = 0; hue <= 360; hue++) { 446 | CGFloat secA = (hue) / 180.0 * M_PI + M_PI; 447 | CGFloat a = radiur * sin(secA); 448 | CGFloat b = radiur * cos(secA); 449 | CGPoint toPoint = CGPointMake(b + center.x, a + center.y); 450 | 451 | UIBezierPath *path = [UIBezierPath bezierPath]; 452 | path.lineWidth = 3; 453 | [path moveToPoint:center]; 454 | [path addLineToPoint:toPoint]; 455 | [path stroke]; 456 | [[UIColor colorWithHue:(1.0 * hue / 360) saturation:1.0 brightness:1.0 alpha:1.0] set]; 457 | } 458 | } 459 | @end 460 | 461 | #pragma mark - LSLCenterCircleView Implementation 462 | 463 | /////////////////////////////////////// 464 | /** LSLCenterCircleView */ 465 | /////////////////////////////////////// 466 | 467 | @interface LSLCenterCircleView : UIView 468 | 469 | @property (nonatomic, strong) LSLSemiCircleView *favoriteColorView; 470 | @property (nonatomic, strong) LSLSemiCircleView *colorView; 471 | 472 | @end 473 | 474 | @interface LSLCenterCircleView () 475 | @end 476 | 477 | @implementation LSLCenterCircleView 478 | 479 | - (instancetype)initWithFrame:(CGRect)frame { 480 | if (self = [super initWithFrame:frame]) { 481 | _favoriteColorView = [[LSLSemiCircleView alloc] init]; 482 | _favoriteColorView.semiCircleColor = [UIColor redColor]; 483 | [_favoriteColorView setOnRight:NO]; 484 | [self addSubview:_favoriteColorView]; 485 | 486 | _colorView = [[LSLSemiCircleView alloc] init]; 487 | _colorView.semiCircleColor = [UIColor redColor]; 488 | [_favoriteColorView setOnRight:YES]; 489 | [self addSubview:_colorView]; 490 | } 491 | return self; 492 | } 493 | 494 | - (void)layoutSubviews { 495 | [super layoutSubviews]; 496 | 497 | CGFloat radius = self.frame.size.width; 498 | _favoriteColorView.frame = CGRectMake(0, 0, radius * 0.5, radius); 499 | _colorView.frame = CGRectMake(radius * 0.5, 0, radius * 0.5, radius); 500 | } 501 | 502 | @end 503 | 504 | #pragma mark - LSLDripView Implementation 505 | 506 | /////////////////////////////////////// 507 | /** LSLDripView */ 508 | /////////////////////////////////////// 509 | 510 | @interface LSLDripView : UIView 511 | @end 512 | 513 | @implementation LSLDripView 514 | 515 | - (instancetype)initWithFrame:(CGRect)frame { 516 | if (self = [super initWithFrame:frame]) { 517 | self.backgroundColor = [UIColor clearColor]; 518 | } 519 | return self; 520 | } 521 | 522 | - (void)drawRect:(CGRect)rect 523 | { 524 | [[UIColor clearColor] set]; 525 | UIRectFill([self bounds]); 526 | 527 | CGSize size = self.frame.size; 528 | CGPoint startPoint = CGPointMake(size.width * 0.5, size.height); 529 | CGPoint leftControllPoint = CGPointMake(- size.width * 0.73, - size.height * 0.23); 530 | CGPoint rightControllPoint = CGPointMake(size.width * 1.73, - size.height * 0.23); 531 | 532 | // border 533 | UIBezierPath* bordeLSLth = [UIBezierPath bezierPath]; 534 | bordeLSLth.lineWidth = 0.5; 535 | bordeLSLth.lineCapStyle = kCGLineCapRound; 536 | bordeLSLth.lineJoinStyle = kCGLineCapRound; 537 | [bordeLSLth moveToPoint:CGPointMake(startPoint.x , startPoint.y)]; 538 | [bordeLSLth addCurveToPoint:CGPointMake(startPoint.x , startPoint.y) 539 | controlPoint1:CGPointMake(leftControllPoint.x, leftControllPoint.y) 540 | controlPoint2:CGPointMake(rightControllPoint.x, rightControllPoint.y)]; 541 | [[UIColor colorWithWhite:0.5 alpha:1.0] set]; 542 | [bordeLSLth fill]; 543 | 544 | // drip 545 | UIBezierPath* dripPath = [UIBezierPath bezierPath]; 546 | dripPath.lineWidth = 0.0; 547 | dripPath.lineCapStyle = kCGLineCapRound; 548 | dripPath.lineJoinStyle = kCGLineCapRound; 549 | [dripPath moveToPoint:CGPointMake(startPoint.x , startPoint.y)]; 550 | [dripPath addCurveToPoint:CGPointMake(startPoint.x , startPoint.y) 551 | controlPoint1:CGPointMake(leftControllPoint.x, leftControllPoint.y) 552 | controlPoint2:CGPointMake(rightControllPoint.x, rightControllPoint.y)]; 553 | [[UIColor whiteColor] set]; 554 | [dripPath fill]; 555 | } 556 | 557 | @end 558 | 559 | #pragma mark - LSLFavoriteColorView Implementation 560 | 561 | ///////////////////////////////////////////// 562 | /** LSLFavoriteColorView */ 563 | ///////////////////////////////////////////// 564 | 565 | typedef void (^PreSelectColorBlock)(UIColor *); 566 | 567 | @interface LSLFavoriteColorView : UIView 568 | 569 | @property (nonatomic, strong) NSMutableArray *preSelectColorArray; 570 | 571 | - (void)updateSelectedColor; 572 | - (void)preSelectColorBlock:(void(^)(UIColor *))preSelectColorBlock; 573 | 574 | @end 575 | 576 | @interface LSLFavoriteColorView () 577 | 578 | @property (nonatomic, strong) NSMutableArray *buttonArray; 579 | @property (nonatomic, strong) NSMutableArray *dotteLineArray; 580 | 581 | @property (nonatomic, strong) UIView *topLineVeiw; 582 | @property (nonatomic, strong) UIView *bottomLineVeiw; 583 | 584 | @property (nonatomic, copy) PreSelectColorBlock preSelectColorBlock; 585 | 586 | @end 587 | 588 | NSInteger const kButtonNumber = 5; 589 | 590 | @implementation LSLFavoriteColorView 591 | 592 | - (instancetype)initWithFrame:(CGRect)frame { 593 | if (self = [super initWithFrame:frame]) { 594 | _preSelectColorArray = [NSMutableArray array]; 595 | _buttonArray = [NSMutableArray array]; 596 | _dotteLineArray = [NSMutableArray array]; 597 | 598 | for (int i = 0; i < kButtonNumber; i++) { 599 | UIButton *colorButton = [[UIButton alloc] init]; 600 | colorButton.userInteractionEnabled = NO; 601 | [colorButton addTarget:self action:@selector(preColor:) forControlEvents:UIControlEventTouchDown]; 602 | [_buttonArray addObject:colorButton]; 603 | [self addSubview:colorButton]; 604 | 605 | CAShapeLayer *dotteLine = [CAShapeLayer layer]; 606 | [colorButton.layer addSublayer:dotteLine]; 607 | [_dotteLineArray addObject:dotteLine]; 608 | } 609 | 610 | // line View 611 | _topLineVeiw = [[UIView alloc] init]; 612 | _topLineVeiw.backgroundColor = [UIColor colorWithWhite:0.7 alpha:1]; 613 | [self addSubview:_topLineVeiw]; 614 | 615 | _bottomLineVeiw = [[UIView alloc] init]; 616 | _bottomLineVeiw.backgroundColor = [UIColor colorWithWhite:0.7 alpha:1]; 617 | [self addSubview:_bottomLineVeiw]; 618 | } 619 | return self; 620 | } 621 | 622 | - (void)layoutSubviews { 623 | [super layoutSubviews]; 624 | 625 | CGFloat maginY = 2; 626 | CGRect frame = self.frame; 627 | CGFloat buttonHeight = frame.size.height - maginY * 2; 628 | CGFloat buttonWidht = buttonHeight; 629 | CGFloat magin = (frame.size.width - kButtonNumber * buttonWidht) / (kButtonNumber + 1) ; 630 | 631 | for (int i = 0; i < self.buttonArray.count; i++) { 632 | UIButton *colorButton = self.buttonArray[i]; 633 | colorButton.frame = CGRectMake(i * (buttonWidht + magin) + magin, maginY, buttonWidht, buttonHeight); 634 | colorButton.layer.cornerRadius = buttonWidht * 0.5; 635 | colorButton.layer.masksToBounds = YES; 636 | 637 | CAShapeLayer *dotteLine = self.dotteLineArray[i]; 638 | CGMutablePathRef dottePath = CGPathCreateMutable(); 639 | dotteLine.lineWidth = 0.5; 640 | dotteLine.strokeColor = [UIColor colorWithWhite:0.7 alpha:1].CGColor; 641 | dotteLine.fillColor = [UIColor clearColor].CGColor; 642 | CGPathAddEllipseInRect(dottePath, nil, CGRectMake(0, 0, buttonWidht, buttonHeight)); 643 | dotteLine.path = dottePath; 644 | NSArray *arr = [[NSArray alloc] initWithObjects:[NSNumber numberWithInt:3],[NSNumber numberWithInt:3], nil]; 645 | dotteLine.lineDashPattern = arr; 646 | dotteLine.lineDashPhase = 1.0; 647 | CGPathRelease(dottePath); 648 | } 649 | 650 | _topLineVeiw.frame = CGRectMake(0, 0, frame.size.width, 0.5); 651 | _bottomLineVeiw.frame = CGRectMake(0, frame.size.height, frame.size.width, 0.5); 652 | } 653 | 654 | - (void)setPreSelectColorArray:(NSMutableArray *)preSelectColorArray 655 | { 656 | _preSelectColorArray = preSelectColorArray; 657 | [self updateSelectedColor]; 658 | } 659 | 660 | - (void)updateSelectedColor 661 | { 662 | for (int i = 0; i < self.preSelectColorArray.count; i++) { 663 | UIColor *color = self.preSelectColorArray[i]; 664 | UIButton *button = self.buttonArray[i]; 665 | button.backgroundColor = color; 666 | button.userInteractionEnabled = YES; 667 | button.layer.borderColor = [UIColor colorWithWhite:0.8 alpha:1].CGColor; 668 | button.layer.borderWidth = 0.1; 669 | 670 | CAShapeLayer *dotteLine = self.dotteLineArray[i]; 671 | [dotteLine removeFromSuperlayer]; 672 | } 673 | } 674 | 675 | #pragma mark - click 676 | 677 | - (void)preColor:(UIButton *)button { 678 | if (self.preSelectColorBlock) { 679 | self.preSelectColorBlock(button.backgroundColor); 680 | } 681 | } 682 | 683 | #pragma mark - block 684 | 685 | - (void)preSelectColorBlock:(void (^)(UIColor *))preSelectColorBlock { 686 | if (preSelectColorBlock) { 687 | self.preSelectColorBlock = preSelectColorBlock; 688 | } 689 | } 690 | 691 | @end 692 | 693 | #pragma mark - LSLHSBColorPickerView Implementation 694 | 695 | ////////////////////////////////////////////////// 696 | /** LSLHSBColorPickerView */ 697 | ////////////////////////////////////////////////// 698 | 699 | typedef void(^ColorSelectedBlock)(UIColor *, BOOL); 700 | 701 | @interface LSLHSBColorPickerView () 702 | 703 | @property (nonatomic, strong) UIColor *color; 704 | 705 | @property (nonatomic, getter=isConfirm) BOOL confirm; 706 | 707 | @property (nonatomic, assign) CGFloat hue; 708 | @property (nonatomic, assign) CGFloat saturation; 709 | @property (nonatomic, assign) CGFloat brightness; 710 | @property (nonatomic, assign) CGFloat alpha; 711 | 712 | @property (nonatomic, strong) UIView *colorCircleView; 713 | @property (nonatomic, strong) LSLCenterCircleView *centerCircleView; 714 | @property (nonatomic, strong) LSLColorCicle *colorView; 715 | 716 | @property (nonatomic, strong) UIButton *dripBtn; 717 | @property (nonatomic, strong) LSLDripView *dripView; 718 | 719 | @property (nonatomic, strong) UIView *lineViewTop; 720 | @property (nonatomic, strong) UIView *lineViewBottom; 721 | 722 | @property (nonatomic, strong) LSLSlider *saturationSlider; 723 | @property (nonatomic, strong) LSLSlider *brightnessSlider; 724 | @property (nonatomic, strong) CAGradientLayer *saturationGradientLayer; 725 | @property (nonatomic, strong) CAGradientLayer *brightnessGradientLayer; 726 | 727 | @property (nonatomic, strong) LSLFavoriteColorView *favoriteColorView; 728 | 729 | @property (nonatomic, copy) ColorSelectedBlock colorSelectedBlock; 730 | 731 | @property (nonatomic, assign) CGFloat radius; 732 | @property (nonatomic, assign) CGFloat dripViewX; 733 | 734 | @property (nonatomic, assign) CGFloat preAngle; 735 | @property (nonatomic, assign) CGFloat preTransformAngle; 736 | 737 | @end 738 | 739 | static CGFloat DripViewWithAndHeight = 38; 740 | 741 | @implementation LSLHSBColorPickerView 742 | 743 | #pragma mark - init 744 | 745 | - (instancetype)initWithFrame:(CGRect)frame { 746 | if (self = [super initWithFrame:frame]) { 747 | [self initialize]; 748 | } 749 | return self; 750 | } 751 | 752 | - (void)initialize 753 | { 754 | _confirm = NO; 755 | _hue = 0.0; 756 | _saturation = 1.0; 757 | _brightness = 1.0; 758 | _alpha = 1.0; 759 | 760 | _preAngle = 0.0; 761 | _preTransformAngle = 0.0; 762 | 763 | // colour circle view 764 | _colorCircleView = [[UIView alloc] init]; 765 | _colorCircleView.backgroundColor = [UIColor clearColor]; 766 | 767 | _colorView = [[LSLColorCicle alloc] init]; 768 | [_colorCircleView addSubview:_colorView]; 769 | 770 | _centerCircleView = [[LSLCenterCircleView alloc] init]; 771 | UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(changePreColor:)]; 772 | [_centerCircleView addGestureRecognizer:tapRecognizer]; 773 | [_colorCircleView addSubview:_centerCircleView]; 774 | 775 | _dripView = [[LSLDripView alloc] init]; 776 | UIPanGestureRecognizer *panRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(changedPositionAndColor:)]; 777 | [_dripView addGestureRecognizer:panRecognizer]; 778 | [_colorCircleView addSubview:_dripView]; 779 | 780 | // animation to show or hidden the menu 781 | _dripBtn = [[UIButton alloc] initWithFrame:_dripView.bounds]; 782 | [_dripBtn addTarget:self action:@selector(showMenuByButtonClick:) forControlEvents:UIControlEventTouchDown]; 783 | [_dripBtn addTarget:self action:@selector(hiddenMenuByButtonClick:) forControlEvents:UIControlEventTouchUpInside]; 784 | [_dripView addSubview:_dripBtn]; 785 | [_dripView bringSubviewToFront:_dripBtn]; 786 | 787 | [self addSubview:_colorCircleView]; 788 | 789 | // top line View 790 | _lineViewTop = [[UIView alloc] init]; 791 | _lineViewTop.backgroundColor = [UIColor colorWithWhite:0.5 alpha:0.2]; 792 | [self addSubview:_lineViewTop]; 793 | 794 | // saturation slider 795 | _saturationSlider = [[LSLSlider alloc] init]; 796 | [self setupSliderWithSliderName:@"saturationSlider"]; 797 | [self addSubview:_saturationSlider]; 798 | 799 | _lineViewBottom = [[UIView alloc] init]; 800 | _lineViewBottom.backgroundColor = [UIColor colorWithWhite:0.5 alpha:0.2]; 801 | [self addSubview:_lineViewBottom]; 802 | 803 | _brightnessSlider = [[LSLSlider alloc] init]; 804 | [self setupSliderWithSliderName:@"brightnessSlider"]; 805 | [self addSubview:_brightnessSlider]; 806 | 807 | // pre selected color view 808 | _favoriteColorView = [[LSLFavoriteColorView alloc] init]; 809 | _favoriteColorView.backgroundColor = [UIColor whiteColor]; 810 | 811 | // setup origin selected colors from local 812 | NSMutableArray *colorArray = [self getSelectedColorFromeArchiver]; 813 | _favoriteColorView.preSelectColorArray = [colorArray mutableCopy]; 814 | if (colorArray.count > 0) { 815 | _preColor = colorArray.firstObject; 816 | _color = _preColor; 817 | } 818 | 819 | __weak typeof(self) weakSelf = self; 820 | [_favoriteColorView preSelectColorBlock:^(UIColor *color) { 821 | weakSelf.color = color; 822 | [weakSelf updateColorAndViewPositionWithAnimation:YES]; 823 | 824 | // return selected color 825 | [weakSelf revertSelectedColorByBlock]; 826 | }]; 827 | [self addSubview:_favoriteColorView]; 828 | } 829 | 830 | - (void)setupSliderWithSliderName:(NSString *)sliderName 831 | { 832 | CAGradientLayer *gradientLayer = [[CAGradientLayer alloc] init]; 833 | gradientLayer.startPoint = CGPointMake(0.0, 0.0); 834 | gradientLayer.endPoint = CGPointMake(1.0, 0.0); 835 | 836 | __weak typeof(self) weakSelf = self; 837 | if ([sliderName isEqualToString:@"saturationSlider"]) { 838 | gradientLayer.frame = _saturationSlider.layer.bounds; 839 | [gradientLayer setColors:[self getMultiSaturationColorWithHue:_hue brightness:_brightness]]; 840 | _saturationGradientLayer = gradientLayer; 841 | 842 | [_saturationSlider.vittaView.layer addSublayer:gradientLayer]; 843 | [_saturationSlider sliderValueChangeBlock:^(CGFloat value, BOOL confirm) { 844 | weakSelf.confirm = confirm; 845 | [weakSelf changeColorBySaturation:weakSelf.saturationSlider]; 846 | }]; 847 | 848 | }else if ([sliderName isEqualToString:@"brightnessSlider"]){ 849 | gradientLayer.frame = _brightnessSlider.layer.bounds; 850 | [gradientLayer setColors:[self getMultiBrightnessColorWithHue:_hue saturation:_saturation]]; 851 | _brightnessGradientLayer = gradientLayer; 852 | 853 | [_brightnessSlider.vittaView.layer addSublayer:gradientLayer]; 854 | [_brightnessSlider sliderValueChangeBlock:^(CGFloat value, BOOL confirm) { 855 | weakSelf.confirm = confirm; 856 | [weakSelf changeColorByBrightness:weakSelf.brightnessSlider]; 857 | }]; 858 | } 859 | } 860 | 861 | #pragma mark - layout subviews 862 | 863 | - (void)layoutSubviews { 864 | [super layoutSubviews]; 865 | 866 | _preAngle = 0.0; 867 | _preTransformAngle = 0.0; 868 | 869 | CGFloat magin = 10; 870 | CGSize size = self.frame.size; 871 | CGFloat square = fmin(size.height, size.width); 872 | size = CGSizeMake(square * 0.75, square * 0.75); 873 | CGFloat x = (self.frame.size.width - size.width) * 0.5; 874 | _radius = size.width * 0.5; 875 | _dripViewX = _radius - DripViewWithAndHeight * 0.5; 876 | CGFloat radiusCenter = (size.width - 24) * 0.5; 877 | 878 | // colour circle view 879 | _colorCircleView.frame = CGRectMake(x, 3, size.width, size.height); 880 | _colorView.frame = CGRectMake(12, 12, size.width - 24, size.height - 24); 881 | 882 | _centerCircleView.frame = CGRectMake(0, 0, radiusCenter - 10, radiusCenter - 10); 883 | _centerCircleView.center = CGPointMake(_radius, _radius); 884 | 885 | // drip view 886 | _dripView.frame = CGRectMake(_dripViewX, 0, DripViewWithAndHeight, DripViewWithAndHeight); 887 | _dripBtn.frame = _dripView.bounds; 888 | 889 | // line View & slider 890 | _lineViewTop.frame = CGRectMake(magin * 2, CGRectGetMaxY(_colorCircleView.frame) + 3, self.frame.size.width - 4 * magin, 0.5); 891 | _saturationSlider.frame = CGRectMake(magin * 0.5, CGRectGetMaxY(_lineViewTop.frame) + 5, self.frame.size.width - magin , 28); 892 | _lineViewBottom.frame = CGRectMake(magin * 2, CGRectGetMaxY(_saturationSlider.frame) + 5, self.frame.size.width - 4 * magin, 0.5); 893 | _brightnessSlider.frame = CGRectMake(magin * 0.5, CGRectGetMaxY(_lineViewBottom.frame) + 5, self.frame.size.width - magin, 28); 894 | _saturationGradientLayer.frame = _saturationSlider.bounds; 895 | _brightnessGradientLayer.frame = _brightnessSlider.layer.bounds; 896 | 897 | // pre selected color view 898 | _favoriteColorView.frame = CGRectMake(0, CGRectGetMaxY(_brightnessSlider.frame) + 8, self.frame.size.width, 35); 899 | 900 | [self updateColorAndViewPositionWithAnimation:NO]; 901 | } 902 | 903 | #pragma mark - gesture recognizer action 904 | 905 | - (void)changedPositionAndColor:(UIGestureRecognizer *)recognizer 906 | { 907 | _confirm = NO; 908 | 909 | switch (recognizer.state) { 910 | case UIGestureRecognizerStateBegan:{ 911 | if ([LSLMenuWindow shareMenuWindow].hidden) { 912 | [self changeMenuFrameAndValue]; 913 | [LSLMenuWindow animationToShowMenu]; 914 | } 915 | break; 916 | } 917 | case UIGestureRecognizerStateChanged:{ 918 | CGPoint point = [recognizer locationInView:_colorCircleView]; 919 | CGFloat dx = point.x - self.radius; 920 | CGFloat dy = point.y - self.radius; 921 | CGFloat angle = atan2f(dy, dx); 922 | if (dy != 0) { 923 | angle += M_PI; 924 | _hue = angle / (2 * M_PI); 925 | } else if (dx > 0) { 926 | _hue = 0.5; 927 | } 928 | [self changeValue]; 929 | [self changeMenuFrameAndValue]; 930 | 931 | break; 932 | } 933 | case UIGestureRecognizerStateEnded: { 934 | _confirm = YES; 935 | [self changeValue]; 936 | [self changeMenuFrameAndValue]; 937 | [LSLMenuWindow animationToHiddenMenu]; 938 | 939 | break; 940 | } 941 | default: { 942 | break; 943 | } 944 | } 945 | } 946 | 947 | #pragma mark - update Color and View Position 948 | 949 | - (void)updateColorAndViewPositionWithAnimation:(BOOL)isAnimation 950 | { 951 | // update hue, saturation, brightness, alpha 952 | [self.color getHue:&_hue saturation:&_saturation brightness:&_brightness alpha:&_alpha]; 953 | 954 | self.centerCircleView.favoriteColorView.semiCircleColor = self.color; 955 | self.centerCircleView.colorView.semiCircleColor = self.color; 956 | 957 | // slider position and color 958 | [self.saturationSlider changeValue:_saturation animation:isAnimation]; 959 | [self.brightnessSlider changeValue:_brightness animation:isAnimation]; 960 | 961 | [self.saturationGradientLayer setColors:[self getMultiSaturationColorWithHue:_hue brightness:_brightness]]; 962 | [self.brightnessGradientLayer setColors:[self getMultiBrightnessColorWithHue:_hue saturation:_saturation]]; 963 | 964 | // dripView positon 965 | if (isAnimation) { 966 | [self changeDripViewPositionWithDuration:kLSLColorPickerAnimationDuration]; 967 | } else { 968 | [self changeDripViewPositionWithDuration:0.01]; 969 | } 970 | } 971 | 972 | #pragma mark - slider action 973 | 974 | - (void)changeColorBySaturation:(LSLSlider *)slider 975 | { 976 | _saturation = slider.value; 977 | [self changeColor]; 978 | } 979 | 980 | - (void)changeColorByBrightness:(LSLSlider *)slider 981 | { 982 | _brightness = slider.value; 983 | [self changeColor]; 984 | } 985 | 986 | - (void)changeColor 987 | { 988 | _color = [UIColor colorWithHue:_hue saturation:_saturation brightness:_brightness alpha:_alpha]; 989 | self.centerCircleView.colorView.semiCircleColor = _color; 990 | 991 | [self.saturationGradientLayer setColors:[self getMultiSaturationColorWithHue:_hue brightness:_brightness]]; 992 | [self.brightnessGradientLayer setColors:[self getMultiBrightnessColorWithHue:_hue saturation:_saturation]]; 993 | 994 | // return selected color 995 | [self revertSelectedColorByBlock]; 996 | } 997 | 998 | - (NSArray *)getMultiSaturationColorWithHue:(CGFloat)hue brightness:(CGFloat)brightness 999 | { 1000 | return @[ 1001 | (id)[UIColor colorWithHue:hue saturation:0.0 brightness:brightness alpha:1.0].CGColor, 1002 | (id)[UIColor colorWithHue:hue saturation:1.0 brightness:brightness alpha:1.0].CGColor 1003 | ]; 1004 | } 1005 | 1006 | - (NSArray *)getMultiBrightnessColorWithHue:(CGFloat)hue saturation:(CGFloat)saturation 1007 | { 1008 | return @[ 1009 | (id)[UIColor colorWithHue:hue saturation:saturation brightness:0.0 alpha:1.0].CGColor, 1010 | (id)[UIColor colorWithHue:hue saturation:saturation brightness:1.0 alpha:1.0].CGColor 1011 | ]; 1012 | } 1013 | 1014 | #pragma mark - change value and position 1015 | 1016 | - (void)changeValue 1017 | { 1018 | [self changeDripViewPositionWithDuration:0.0]; 1019 | 1020 | // current selected color 1021 | [self changeColor]; 1022 | 1023 | // slider color 1024 | [self.saturationGradientLayer setColors:[self getMultiSaturationColorWithHue:_hue brightness:_brightness]]; 1025 | [self.brightnessGradientLayer setColors:[self getMultiBrightnessColorWithHue:_hue saturation:_saturation]]; 1026 | } 1027 | 1028 | - (void)changeDripViewPositionWithDuration:(CGFloat)duration 1029 | { 1030 | CGFloat currentAngle = M_PI * 2 * _hue - M_PI; 1031 | 1032 | // prevent repeated clicks 1033 | if (self.preAngle != 0 && currentAngle == self.preAngle) return; 1034 | 1035 | CGFloat cx = self.dripViewX * cos(currentAngle) + self.dripViewX; 1036 | CGFloat cy = self.dripViewX * sin(currentAngle) + self.dripViewX; 1037 | CGRect frame = self.dripView.frame; 1038 | frame.origin.x = cx; 1039 | frame.origin.y = cy; 1040 | self.dripView.frame = frame; 1041 | 1042 | // dripView shadow 1043 | CGFloat offsetX = 2 * cos(currentAngle); 1044 | CGFloat offsetY = 2 * sin(currentAngle + M_PI); 1045 | self.dripView.layer.shadowOffset = CGSizeMake(offsetX, offsetY); 1046 | self.dripView.layer.shadowRadius = 4; 1047 | self.dripView.layer.shadowOpacity = 0.2; 1048 | 1049 | // dripView animation 1050 | CAKeyframeAnimation *positionAnimation = [[CAKeyframeAnimation alloc] init]; 1051 | positionAnimation.rotationMode = kCAAnimationRotateAuto; 1052 | 1053 | BOOL isClockwise = YES; 1054 | if ((currentAngle < self.preAngle && currentAngle - self.preAngle > - M_PI) || (currentAngle - self.preAngle > M_PI)) { 1055 | isClockwise = NO; 1056 | positionAnimation.rotationMode = kCAAnimationRotateAutoReverse; 1057 | } 1058 | positionAnimation.keyPath = @"position"; 1059 | positionAnimation.path = [UIBezierPath bezierPathWithArcCenter:_centerCircleView.center 1060 | radius:self.dripViewX 1061 | startAngle:self.preAngle 1062 | endAngle:currentAngle 1063 | clockwise:isClockwise].CGPath; 1064 | positionAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; 1065 | positionAnimation.repeatCount = 1; 1066 | positionAnimation.duration = duration; 1067 | positionAnimation.fillMode = kCAFillModeBoth; 1068 | positionAnimation.removedOnCompletion = NO; 1069 | [self.dripView.layer addAnimation:positionAnimation forKey:@"positionAnimation"]; 1070 | 1071 | self.preAngle = currentAngle; 1072 | } 1073 | 1074 | - (void)changePreColor:(UITapGestureRecognizer *)recognizer 1075 | { 1076 | self.color = self.centerCircleView.favoriteColorView.semiCircleColor; 1077 | [self updateColorAndViewPositionWithAnimation:YES]; 1078 | 1079 | // return selected color 1080 | [self revertSelectedColorByBlock]; 1081 | } 1082 | 1083 | #pragma mark - menu 1084 | 1085 | - (void)hiddenMenuByButtonClick:(UIButton *)button { 1086 | [LSLMenuWindow animationToHiddenMenu]; 1087 | } 1088 | 1089 | - (void)showMenuByButtonClick:(UIButton *)button { 1090 | [self changeMenuFrameAndValue]; 1091 | [LSLMenuWindow animationToShowMenu]; 1092 | } 1093 | 1094 | - (void)changeMenuFrameAndValue 1095 | { 1096 | CGPoint origin = [[LSLMenuWindow shareMenuWindow] convertPoint:self.dripView.center fromView:self.dripView.superview]; 1097 | CGRect dripFrame = self.dripView.frame; 1098 | CGRect menuFrame = [LSLMenuWindow shareMenuWindow].frame; 1099 | menuFrame.origin.x = origin.x - dripFrame.size.width; 1100 | menuFrame.origin.y = origin.y - menuFrame.size.height - 20; 1101 | 1102 | [[LSLMenuWindow shareMenuWindow] updateWithFrame:menuFrame]; 1103 | [LSLMenuWindow shareMenuWindow].titleLabel.text = [NSString stringWithFormat:@"%.0f°",_hue * 360]; 1104 | } 1105 | 1106 | #pragma mark - save and get selected color frome archiver 1107 | 1108 | - (void)saveSelectedColorsToArchiver 1109 | { 1110 | self.color = self.centerCircleView.colorView.semiCircleColor; 1111 | 1112 | // remove the same color in array 1113 | for (int i = 0; i < self.favoriteColorView.preSelectColorArray.count; i++) { 1114 | UIColor *color = self.favoriteColorView.preSelectColorArray[i]; 1115 | if (CGColorEqualToColor(self.color.CGColor, color.CGColor)) { 1116 | [self.favoriteColorView.preSelectColorArray removeObject:color]; 1117 | } 1118 | } 1119 | 1120 | // array count max 5 1121 | if (self.favoriteColorView.preSelectColorArray.count >= 5) { 1122 | [self.favoriteColorView.preSelectColorArray removeLastObject]; 1123 | } 1124 | [self.favoriteColorView.preSelectColorArray insertObject:self.color atIndex:0]; 1125 | [self.favoriteColorView updateSelectedColor]; 1126 | 1127 | // archiver 1128 | NSString *documents = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject]; 1129 | NSString *path = [documents stringByAppendingPathComponent:@"preColor.archiver"]; 1130 | BOOL isSuccess = [NSKeyedArchiver archiveRootObject:self.favoriteColorView.preSelectColorArray toFile:path]; 1131 | if (!isSuccess) { 1132 | NSLog(@"It's archiver selected color error"); 1133 | } 1134 | } 1135 | 1136 | - (NSMutableArray *)getSelectedColorFromeArchiver 1137 | { 1138 | NSString *documents = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject]; 1139 | NSString *path = [documents stringByAppendingPathComponent:@"preColor.archiver"]; 1140 | NSMutableArray *preColor = [NSKeyedUnarchiver unarchiveObjectWithFile:path]; 1141 | if (preColor) { 1142 | return [preColor mutableCopy]; 1143 | } 1144 | return [NSMutableArray array]; 1145 | } 1146 | 1147 | + (void)cleanSelectedColorsInArchiver 1148 | { 1149 | NSString *documents = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject]; 1150 | NSString *path = [documents stringByAppendingPathComponent:@"preColor.archiver"]; 1151 | NSFileManager *defaultManager = [NSFileManager defaultManager]; 1152 | if ([defaultManager fileExistsAtPath:path]) { 1153 | [defaultManager removeItemAtPath:path error:nil]; 1154 | } 1155 | } 1156 | 1157 | #pragma mark - block 1158 | 1159 | - (void)colorSelectedBlock:(void (^)(UIColor *, BOOL))colorSelectedBlock { 1160 | if (colorSelectedBlock) { 1161 | self.colorSelectedBlock = colorSelectedBlock; 1162 | } 1163 | } 1164 | 1165 | - (void)revertSelectedColorByBlock { 1166 | if (self.colorSelectedBlock) { 1167 | self.colorSelectedBlock(self.color, self.isConfirm); 1168 | } 1169 | } 1170 | 1171 | @end 1172 | -------------------------------------------------------------------------------- /LSLColorPikerDemo/GIF/colorPickerView.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SilongLi/ColorPickerView/9c46eaab23f99917d6c9989bad60e000b8caf8cf/LSLColorPikerDemo/GIF/colorPickerView.gif -------------------------------------------------------------------------------- /LSLColorPikerDemo/LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /LSLColorPikerDemo/LSLColorPickerDemo.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 99AC12A61C300B4C0079CE4C /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 99AC12A51C300B4C0079CE4C /* main.m */; }; 11 | 99AC12A91C300B4C0079CE4C /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 99AC12A81C300B4C0079CE4C /* AppDelegate.m */; }; 12 | 99AC12AC1C300B4C0079CE4C /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 99AC12AB1C300B4C0079CE4C /* ViewController.m */; }; 13 | 99AC12AF1C300B4C0079CE4C /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 99AC12AD1C300B4C0079CE4C /* Main.storyboard */; }; 14 | 99AC12B11C300B4C0079CE4C /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 99AC12B01C300B4C0079CE4C /* Assets.xcassets */; }; 15 | 99AC12B41C300B4C0079CE4C /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 99AC12B21C300B4C0079CE4C /* LaunchScreen.storyboard */; }; 16 | 99AC12BF1C300B4C0079CE4C /* LSLColorPikerDemoTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 99AC12BE1C300B4C0079CE4C /* LSLColorPikerDemoTests.m */; }; 17 | 99AC12CA1C300B4C0079CE4C /* LSLColorPikerDemoUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = 99AC12C91C300B4C0079CE4C /* LSLColorPikerDemoUITests.m */; }; 18 | 99FA5E381DE05D79001D11D8 /* LSLHSBColorPickerView.m in Sources */ = {isa = PBXBuildFile; fileRef = 99FA5E371DE05D79001D11D8 /* LSLHSBColorPickerView.m */; }; 19 | /* End PBXBuildFile section */ 20 | 21 | /* Begin PBXContainerItemProxy section */ 22 | 99AC12BB1C300B4C0079CE4C /* PBXContainerItemProxy */ = { 23 | isa = PBXContainerItemProxy; 24 | containerPortal = 99AC12991C300B4C0079CE4C /* Project object */; 25 | proxyType = 1; 26 | remoteGlobalIDString = 99AC12A01C300B4C0079CE4C; 27 | remoteInfo = LSLColorPikerDemo; 28 | }; 29 | 99AC12C61C300B4C0079CE4C /* PBXContainerItemProxy */ = { 30 | isa = PBXContainerItemProxy; 31 | containerPortal = 99AC12991C300B4C0079CE4C /* Project object */; 32 | proxyType = 1; 33 | remoteGlobalIDString = 99AC12A01C300B4C0079CE4C; 34 | remoteInfo = LSLColorPikerDemo; 35 | }; 36 | /* End PBXContainerItemProxy section */ 37 | 38 | /* Begin PBXFileReference section */ 39 | 99AC12A11C300B4C0079CE4C /* LSLColorPickerDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = LSLColorPickerDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 40 | 99AC12A51C300B4C0079CE4C /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 41 | 99AC12A71C300B4C0079CE4C /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 42 | 99AC12A81C300B4C0079CE4C /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 43 | 99AC12AA1C300B4C0079CE4C /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 44 | 99AC12AB1C300B4C0079CE4C /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 45 | 99AC12AE1C300B4C0079CE4C /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 46 | 99AC12B01C300B4C0079CE4C /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 47 | 99AC12B31C300B4C0079CE4C /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 48 | 99AC12B51C300B4C0079CE4C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 49 | 99AC12BA1C300B4C0079CE4C /* LSLColorPickerDemoTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = LSLColorPickerDemoTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 50 | 99AC12BE1C300B4C0079CE4C /* LSLColorPikerDemoTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = LSLColorPikerDemoTests.m; sourceTree = ""; }; 51 | 99AC12C01C300B4C0079CE4C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 52 | 99AC12C51C300B4C0079CE4C /* LSLColorPickerDemoUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = LSLColorPickerDemoUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 53 | 99AC12C91C300B4C0079CE4C /* LSLColorPikerDemoUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = LSLColorPikerDemoUITests.m; sourceTree = ""; }; 54 | 99AC12CB1C300B4C0079CE4C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 55 | 99FA5E361DE05D79001D11D8 /* LSLHSBColorPickerView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LSLHSBColorPickerView.h; sourceTree = ""; }; 56 | 99FA5E371DE05D79001D11D8 /* LSLHSBColorPickerView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LSLHSBColorPickerView.m; sourceTree = ""; }; 57 | /* End PBXFileReference section */ 58 | 59 | /* Begin PBXFrameworksBuildPhase section */ 60 | 99AC129E1C300B4C0079CE4C /* Frameworks */ = { 61 | isa = PBXFrameworksBuildPhase; 62 | buildActionMask = 2147483647; 63 | files = ( 64 | ); 65 | runOnlyForDeploymentPostprocessing = 0; 66 | }; 67 | 99AC12B71C300B4C0079CE4C /* Frameworks */ = { 68 | isa = PBXFrameworksBuildPhase; 69 | buildActionMask = 2147483647; 70 | files = ( 71 | ); 72 | runOnlyForDeploymentPostprocessing = 0; 73 | }; 74 | 99AC12C21C300B4C0079CE4C /* Frameworks */ = { 75 | isa = PBXFrameworksBuildPhase; 76 | buildActionMask = 2147483647; 77 | files = ( 78 | ); 79 | runOnlyForDeploymentPostprocessing = 0; 80 | }; 81 | /* End PBXFrameworksBuildPhase section */ 82 | 83 | /* Begin PBXGroup section */ 84 | 99AC12981C300B4C0079CE4C = { 85 | isa = PBXGroup; 86 | children = ( 87 | 99AC12EA1C300BA50079CE4C /* ColorPickerClass */, 88 | 99AC12A31C300B4C0079CE4C /* LSLColorPickerDemo */, 89 | 99AC12BD1C300B4C0079CE4C /* LSLColorPickerDemoTests */, 90 | 99AC12C81C300B4C0079CE4C /* LSLColorPickerDemoUITests */, 91 | 99AC12A21C300B4C0079CE4C /* Products */, 92 | ); 93 | sourceTree = ""; 94 | }; 95 | 99AC12A21C300B4C0079CE4C /* Products */ = { 96 | isa = PBXGroup; 97 | children = ( 98 | 99AC12A11C300B4C0079CE4C /* LSLColorPickerDemo.app */, 99 | 99AC12BA1C300B4C0079CE4C /* LSLColorPickerDemoTests.xctest */, 100 | 99AC12C51C300B4C0079CE4C /* LSLColorPickerDemoUITests.xctest */, 101 | ); 102 | name = Products; 103 | sourceTree = ""; 104 | }; 105 | 99AC12A31C300B4C0079CE4C /* LSLColorPickerDemo */ = { 106 | isa = PBXGroup; 107 | children = ( 108 | 99AC12A71C300B4C0079CE4C /* AppDelegate.h */, 109 | 99AC12A81C300B4C0079CE4C /* AppDelegate.m */, 110 | 99AC12AA1C300B4C0079CE4C /* ViewController.h */, 111 | 99AC12AB1C300B4C0079CE4C /* ViewController.m */, 112 | 99AC12AD1C300B4C0079CE4C /* Main.storyboard */, 113 | 99AC12B01C300B4C0079CE4C /* Assets.xcassets */, 114 | 99AC12B21C300B4C0079CE4C /* LaunchScreen.storyboard */, 115 | 99AC12B51C300B4C0079CE4C /* Info.plist */, 116 | 99AC12A41C300B4C0079CE4C /* Supporting Files */, 117 | ); 118 | name = LSLColorPickerDemo; 119 | path = LSLColorPikerDemo; 120 | sourceTree = ""; 121 | }; 122 | 99AC12A41C300B4C0079CE4C /* Supporting Files */ = { 123 | isa = PBXGroup; 124 | children = ( 125 | 99AC12A51C300B4C0079CE4C /* main.m */, 126 | ); 127 | name = "Supporting Files"; 128 | sourceTree = ""; 129 | }; 130 | 99AC12BD1C300B4C0079CE4C /* LSLColorPickerDemoTests */ = { 131 | isa = PBXGroup; 132 | children = ( 133 | 99AC12BE1C300B4C0079CE4C /* LSLColorPikerDemoTests.m */, 134 | 99AC12C01C300B4C0079CE4C /* Info.plist */, 135 | ); 136 | name = LSLColorPickerDemoTests; 137 | path = LSLColorPikerDemoTests; 138 | sourceTree = ""; 139 | }; 140 | 99AC12C81C300B4C0079CE4C /* LSLColorPickerDemoUITests */ = { 141 | isa = PBXGroup; 142 | children = ( 143 | 99AC12C91C300B4C0079CE4C /* LSLColorPikerDemoUITests.m */, 144 | 99AC12CB1C300B4C0079CE4C /* Info.plist */, 145 | ); 146 | name = LSLColorPickerDemoUITests; 147 | path = LSLColorPikerDemoUITests; 148 | sourceTree = ""; 149 | }; 150 | 99AC12EA1C300BA50079CE4C /* ColorPickerClass */ = { 151 | isa = PBXGroup; 152 | children = ( 153 | 99FA5E361DE05D79001D11D8 /* LSLHSBColorPickerView.h */, 154 | 99FA5E371DE05D79001D11D8 /* LSLHSBColorPickerView.m */, 155 | ); 156 | path = ColorPickerClass; 157 | sourceTree = ""; 158 | }; 159 | /* End PBXGroup section */ 160 | 161 | /* Begin PBXNativeTarget section */ 162 | 99AC12A01C300B4C0079CE4C /* LSLColorPickerDemo */ = { 163 | isa = PBXNativeTarget; 164 | buildConfigurationList = 99AC12CE1C300B4C0079CE4C /* Build configuration list for PBXNativeTarget "LSLColorPickerDemo" */; 165 | buildPhases = ( 166 | 99AC129D1C300B4C0079CE4C /* Sources */, 167 | 99AC129E1C300B4C0079CE4C /* Frameworks */, 168 | 99AC129F1C300B4C0079CE4C /* Resources */, 169 | ); 170 | buildRules = ( 171 | ); 172 | dependencies = ( 173 | ); 174 | name = LSLColorPickerDemo; 175 | productName = LSLColorPikerDemo; 176 | productReference = 99AC12A11C300B4C0079CE4C /* LSLColorPickerDemo.app */; 177 | productType = "com.apple.product-type.application"; 178 | }; 179 | 99AC12B91C300B4C0079CE4C /* LSLColorPickerDemoTests */ = { 180 | isa = PBXNativeTarget; 181 | buildConfigurationList = 99AC12D11C300B4C0079CE4C /* Build configuration list for PBXNativeTarget "LSLColorPickerDemoTests" */; 182 | buildPhases = ( 183 | 99AC12B61C300B4C0079CE4C /* Sources */, 184 | 99AC12B71C300B4C0079CE4C /* Frameworks */, 185 | 99AC12B81C300B4C0079CE4C /* Resources */, 186 | ); 187 | buildRules = ( 188 | ); 189 | dependencies = ( 190 | 99AC12BC1C300B4C0079CE4C /* PBXTargetDependency */, 191 | ); 192 | name = LSLColorPickerDemoTests; 193 | productName = LSLColorPikerDemoTests; 194 | productReference = 99AC12BA1C300B4C0079CE4C /* LSLColorPickerDemoTests.xctest */; 195 | productType = "com.apple.product-type.bundle.unit-test"; 196 | }; 197 | 99AC12C41C300B4C0079CE4C /* LSLColorPickerDemoUITests */ = { 198 | isa = PBXNativeTarget; 199 | buildConfigurationList = 99AC12D41C300B4C0079CE4C /* Build configuration list for PBXNativeTarget "LSLColorPickerDemoUITests" */; 200 | buildPhases = ( 201 | 99AC12C11C300B4C0079CE4C /* Sources */, 202 | 99AC12C21C300B4C0079CE4C /* Frameworks */, 203 | 99AC12C31C300B4C0079CE4C /* Resources */, 204 | ); 205 | buildRules = ( 206 | ); 207 | dependencies = ( 208 | 99AC12C71C300B4C0079CE4C /* PBXTargetDependency */, 209 | ); 210 | name = LSLColorPickerDemoUITests; 211 | productName = LSLColorPikerDemoUITests; 212 | productReference = 99AC12C51C300B4C0079CE4C /* LSLColorPickerDemoUITests.xctest */; 213 | productType = "com.apple.product-type.bundle.ui-testing"; 214 | }; 215 | /* End PBXNativeTarget section */ 216 | 217 | /* Begin PBXProject section */ 218 | 99AC12991C300B4C0079CE4C /* Project object */ = { 219 | isa = PBXProject; 220 | attributes = { 221 | LastUpgradeCheck = 0720; 222 | ORGANIZATIONNAME = longshao; 223 | TargetAttributes = { 224 | 99AC12A01C300B4C0079CE4C = { 225 | CreatedOnToolsVersion = 7.2; 226 | DevelopmentTeam = HBBKUSRZMD; 227 | }; 228 | 99AC12B91C300B4C0079CE4C = { 229 | CreatedOnToolsVersion = 7.2; 230 | TestTargetID = 99AC12A01C300B4C0079CE4C; 231 | }; 232 | 99AC12C41C300B4C0079CE4C = { 233 | CreatedOnToolsVersion = 7.2; 234 | TestTargetID = 99AC12A01C300B4C0079CE4C; 235 | }; 236 | }; 237 | }; 238 | buildConfigurationList = 99AC129C1C300B4C0079CE4C /* Build configuration list for PBXProject "LSLColorPickerDemo" */; 239 | compatibilityVersion = "Xcode 3.2"; 240 | developmentRegion = English; 241 | hasScannedForEncodings = 0; 242 | knownRegions = ( 243 | en, 244 | Base, 245 | ); 246 | mainGroup = 99AC12981C300B4C0079CE4C; 247 | productRefGroup = 99AC12A21C300B4C0079CE4C /* Products */; 248 | projectDirPath = ""; 249 | projectRoot = ""; 250 | targets = ( 251 | 99AC12A01C300B4C0079CE4C /* LSLColorPickerDemo */, 252 | 99AC12B91C300B4C0079CE4C /* LSLColorPickerDemoTests */, 253 | 99AC12C41C300B4C0079CE4C /* LSLColorPickerDemoUITests */, 254 | ); 255 | }; 256 | /* End PBXProject section */ 257 | 258 | /* Begin PBXResourcesBuildPhase section */ 259 | 99AC129F1C300B4C0079CE4C /* Resources */ = { 260 | isa = PBXResourcesBuildPhase; 261 | buildActionMask = 2147483647; 262 | files = ( 263 | 99AC12B41C300B4C0079CE4C /* LaunchScreen.storyboard in Resources */, 264 | 99AC12B11C300B4C0079CE4C /* Assets.xcassets in Resources */, 265 | 99AC12AF1C300B4C0079CE4C /* Main.storyboard in Resources */, 266 | ); 267 | runOnlyForDeploymentPostprocessing = 0; 268 | }; 269 | 99AC12B81C300B4C0079CE4C /* Resources */ = { 270 | isa = PBXResourcesBuildPhase; 271 | buildActionMask = 2147483647; 272 | files = ( 273 | ); 274 | runOnlyForDeploymentPostprocessing = 0; 275 | }; 276 | 99AC12C31C300B4C0079CE4C /* Resources */ = { 277 | isa = PBXResourcesBuildPhase; 278 | buildActionMask = 2147483647; 279 | files = ( 280 | ); 281 | runOnlyForDeploymentPostprocessing = 0; 282 | }; 283 | /* End PBXResourcesBuildPhase section */ 284 | 285 | /* Begin PBXSourcesBuildPhase section */ 286 | 99AC129D1C300B4C0079CE4C /* Sources */ = { 287 | isa = PBXSourcesBuildPhase; 288 | buildActionMask = 2147483647; 289 | files = ( 290 | 99AC12AC1C300B4C0079CE4C /* ViewController.m in Sources */, 291 | 99AC12A91C300B4C0079CE4C /* AppDelegate.m in Sources */, 292 | 99FA5E381DE05D79001D11D8 /* LSLHSBColorPickerView.m in Sources */, 293 | 99AC12A61C300B4C0079CE4C /* main.m in Sources */, 294 | ); 295 | runOnlyForDeploymentPostprocessing = 0; 296 | }; 297 | 99AC12B61C300B4C0079CE4C /* Sources */ = { 298 | isa = PBXSourcesBuildPhase; 299 | buildActionMask = 2147483647; 300 | files = ( 301 | 99AC12BF1C300B4C0079CE4C /* LSLColorPikerDemoTests.m in Sources */, 302 | ); 303 | runOnlyForDeploymentPostprocessing = 0; 304 | }; 305 | 99AC12C11C300B4C0079CE4C /* Sources */ = { 306 | isa = PBXSourcesBuildPhase; 307 | buildActionMask = 2147483647; 308 | files = ( 309 | 99AC12CA1C300B4C0079CE4C /* LSLColorPikerDemoUITests.m in Sources */, 310 | ); 311 | runOnlyForDeploymentPostprocessing = 0; 312 | }; 313 | /* End PBXSourcesBuildPhase section */ 314 | 315 | /* Begin PBXTargetDependency section */ 316 | 99AC12BC1C300B4C0079CE4C /* PBXTargetDependency */ = { 317 | isa = PBXTargetDependency; 318 | target = 99AC12A01C300B4C0079CE4C /* LSLColorPickerDemo */; 319 | targetProxy = 99AC12BB1C300B4C0079CE4C /* PBXContainerItemProxy */; 320 | }; 321 | 99AC12C71C300B4C0079CE4C /* PBXTargetDependency */ = { 322 | isa = PBXTargetDependency; 323 | target = 99AC12A01C300B4C0079CE4C /* LSLColorPickerDemo */; 324 | targetProxy = 99AC12C61C300B4C0079CE4C /* PBXContainerItemProxy */; 325 | }; 326 | /* End PBXTargetDependency section */ 327 | 328 | /* Begin PBXVariantGroup section */ 329 | 99AC12AD1C300B4C0079CE4C /* Main.storyboard */ = { 330 | isa = PBXVariantGroup; 331 | children = ( 332 | 99AC12AE1C300B4C0079CE4C /* Base */, 333 | ); 334 | name = Main.storyboard; 335 | sourceTree = ""; 336 | }; 337 | 99AC12B21C300B4C0079CE4C /* LaunchScreen.storyboard */ = { 338 | isa = PBXVariantGroup; 339 | children = ( 340 | 99AC12B31C300B4C0079CE4C /* Base */, 341 | ); 342 | name = LaunchScreen.storyboard; 343 | sourceTree = ""; 344 | }; 345 | /* End PBXVariantGroup section */ 346 | 347 | /* Begin XCBuildConfiguration section */ 348 | 99AC12CC1C300B4C0079CE4C /* Debug */ = { 349 | isa = XCBuildConfiguration; 350 | buildSettings = { 351 | ALWAYS_SEARCH_USER_PATHS = NO; 352 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 353 | CLANG_CXX_LIBRARY = "libc++"; 354 | CLANG_ENABLE_MODULES = YES; 355 | CLANG_ENABLE_OBJC_ARC = YES; 356 | CLANG_WARN_BOOL_CONVERSION = YES; 357 | CLANG_WARN_CONSTANT_CONVERSION = YES; 358 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 359 | CLANG_WARN_EMPTY_BODY = YES; 360 | CLANG_WARN_ENUM_CONVERSION = YES; 361 | CLANG_WARN_INT_CONVERSION = YES; 362 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 363 | CLANG_WARN_UNREACHABLE_CODE = YES; 364 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 365 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 366 | COPY_PHASE_STRIP = NO; 367 | DEBUG_INFORMATION_FORMAT = dwarf; 368 | ENABLE_STRICT_OBJC_MSGSEND = YES; 369 | ENABLE_TESTABILITY = YES; 370 | GCC_C_LANGUAGE_STANDARD = gnu99; 371 | GCC_DYNAMIC_NO_PIC = NO; 372 | GCC_NO_COMMON_BLOCKS = YES; 373 | GCC_OPTIMIZATION_LEVEL = 0; 374 | GCC_PREPROCESSOR_DEFINITIONS = ( 375 | "DEBUG=1", 376 | "$(inherited)", 377 | ); 378 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 379 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 380 | GCC_WARN_UNDECLARED_SELECTOR = YES; 381 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 382 | GCC_WARN_UNUSED_FUNCTION = YES; 383 | GCC_WARN_UNUSED_VARIABLE = YES; 384 | IPHONEOS_DEPLOYMENT_TARGET = 9.2; 385 | MTL_ENABLE_DEBUG_INFO = YES; 386 | ONLY_ACTIVE_ARCH = YES; 387 | SDKROOT = iphoneos; 388 | }; 389 | name = Debug; 390 | }; 391 | 99AC12CD1C300B4C0079CE4C /* Release */ = { 392 | isa = XCBuildConfiguration; 393 | buildSettings = { 394 | ALWAYS_SEARCH_USER_PATHS = NO; 395 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 396 | CLANG_CXX_LIBRARY = "libc++"; 397 | CLANG_ENABLE_MODULES = YES; 398 | CLANG_ENABLE_OBJC_ARC = YES; 399 | CLANG_WARN_BOOL_CONVERSION = YES; 400 | CLANG_WARN_CONSTANT_CONVERSION = YES; 401 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 402 | CLANG_WARN_EMPTY_BODY = YES; 403 | CLANG_WARN_ENUM_CONVERSION = YES; 404 | CLANG_WARN_INT_CONVERSION = YES; 405 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 406 | CLANG_WARN_UNREACHABLE_CODE = YES; 407 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 408 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 409 | COPY_PHASE_STRIP = NO; 410 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 411 | ENABLE_NS_ASSERTIONS = NO; 412 | ENABLE_STRICT_OBJC_MSGSEND = YES; 413 | GCC_C_LANGUAGE_STANDARD = gnu99; 414 | GCC_NO_COMMON_BLOCKS = YES; 415 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 416 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 417 | GCC_WARN_UNDECLARED_SELECTOR = YES; 418 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 419 | GCC_WARN_UNUSED_FUNCTION = YES; 420 | GCC_WARN_UNUSED_VARIABLE = YES; 421 | IPHONEOS_DEPLOYMENT_TARGET = 9.2; 422 | MTL_ENABLE_DEBUG_INFO = NO; 423 | SDKROOT = iphoneos; 424 | VALIDATE_PRODUCT = YES; 425 | }; 426 | name = Release; 427 | }; 428 | 99AC12CF1C300B4C0079CE4C /* Debug */ = { 429 | isa = XCBuildConfiguration; 430 | buildSettings = { 431 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 432 | DEVELOPMENT_TEAM = HBBKUSRZMD; 433 | INFOPLIST_FILE = LSLColorPikerDemo/Info.plist; 434 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 435 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 436 | PRODUCT_BUNDLE_IDENTIFIER = com.longshao.LSLColorPikerDemo; 437 | PRODUCT_NAME = "$(TARGET_NAME)"; 438 | }; 439 | name = Debug; 440 | }; 441 | 99AC12D01C300B4C0079CE4C /* Release */ = { 442 | isa = XCBuildConfiguration; 443 | buildSettings = { 444 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 445 | DEVELOPMENT_TEAM = HBBKUSRZMD; 446 | INFOPLIST_FILE = LSLColorPikerDemo/Info.plist; 447 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 448 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 449 | PRODUCT_BUNDLE_IDENTIFIER = com.longshao.LSLColorPikerDemo; 450 | PRODUCT_NAME = "$(TARGET_NAME)"; 451 | }; 452 | name = Release; 453 | }; 454 | 99AC12D21C300B4C0079CE4C /* Debug */ = { 455 | isa = XCBuildConfiguration; 456 | buildSettings = { 457 | BUNDLE_LOADER = "$(TEST_HOST)"; 458 | INFOPLIST_FILE = LSLColorPikerDemoTests/Info.plist; 459 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 460 | PRODUCT_BUNDLE_IDENTIFIER = com.longshao.LSLColorPikerDemoTests; 461 | PRODUCT_NAME = "$(TARGET_NAME)"; 462 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/LSLColorPickerDemo.app/LSLColorPickerDemo"; 463 | }; 464 | name = Debug; 465 | }; 466 | 99AC12D31C300B4C0079CE4C /* Release */ = { 467 | isa = XCBuildConfiguration; 468 | buildSettings = { 469 | BUNDLE_LOADER = "$(TEST_HOST)"; 470 | INFOPLIST_FILE = LSLColorPikerDemoTests/Info.plist; 471 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 472 | PRODUCT_BUNDLE_IDENTIFIER = com.longshao.LSLColorPikerDemoTests; 473 | PRODUCT_NAME = "$(TARGET_NAME)"; 474 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/LSLColorPickerDemo.app/LSLColorPickerDemo"; 475 | }; 476 | name = Release; 477 | }; 478 | 99AC12D51C300B4C0079CE4C /* Debug */ = { 479 | isa = XCBuildConfiguration; 480 | buildSettings = { 481 | INFOPLIST_FILE = LSLColorPikerDemoUITests/Info.plist; 482 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 483 | PRODUCT_BUNDLE_IDENTIFIER = com.longshao.LSLColorPikerDemoUITests; 484 | PRODUCT_NAME = "$(TARGET_NAME)"; 485 | TEST_TARGET_NAME = LSLColorPikerDemo; 486 | USES_XCTRUNNER = YES; 487 | }; 488 | name = Debug; 489 | }; 490 | 99AC12D61C300B4C0079CE4C /* Release */ = { 491 | isa = XCBuildConfiguration; 492 | buildSettings = { 493 | INFOPLIST_FILE = LSLColorPikerDemoUITests/Info.plist; 494 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 495 | PRODUCT_BUNDLE_IDENTIFIER = com.longshao.LSLColorPikerDemoUITests; 496 | PRODUCT_NAME = "$(TARGET_NAME)"; 497 | TEST_TARGET_NAME = LSLColorPikerDemo; 498 | USES_XCTRUNNER = YES; 499 | }; 500 | name = Release; 501 | }; 502 | /* End XCBuildConfiguration section */ 503 | 504 | /* Begin XCConfigurationList section */ 505 | 99AC129C1C300B4C0079CE4C /* Build configuration list for PBXProject "LSLColorPickerDemo" */ = { 506 | isa = XCConfigurationList; 507 | buildConfigurations = ( 508 | 99AC12CC1C300B4C0079CE4C /* Debug */, 509 | 99AC12CD1C300B4C0079CE4C /* Release */, 510 | ); 511 | defaultConfigurationIsVisible = 0; 512 | defaultConfigurationName = Release; 513 | }; 514 | 99AC12CE1C300B4C0079CE4C /* Build configuration list for PBXNativeTarget "LSLColorPickerDemo" */ = { 515 | isa = XCConfigurationList; 516 | buildConfigurations = ( 517 | 99AC12CF1C300B4C0079CE4C /* Debug */, 518 | 99AC12D01C300B4C0079CE4C /* Release */, 519 | ); 520 | defaultConfigurationIsVisible = 0; 521 | defaultConfigurationName = Release; 522 | }; 523 | 99AC12D11C300B4C0079CE4C /* Build configuration list for PBXNativeTarget "LSLColorPickerDemoTests" */ = { 524 | isa = XCConfigurationList; 525 | buildConfigurations = ( 526 | 99AC12D21C300B4C0079CE4C /* Debug */, 527 | 99AC12D31C300B4C0079CE4C /* Release */, 528 | ); 529 | defaultConfigurationIsVisible = 0; 530 | defaultConfigurationName = Release; 531 | }; 532 | 99AC12D41C300B4C0079CE4C /* Build configuration list for PBXNativeTarget "LSLColorPickerDemoUITests" */ = { 533 | isa = XCConfigurationList; 534 | buildConfigurations = ( 535 | 99AC12D51C300B4C0079CE4C /* Debug */, 536 | 99AC12D61C300B4C0079CE4C /* Release */, 537 | ); 538 | defaultConfigurationIsVisible = 0; 539 | defaultConfigurationName = Release; 540 | }; 541 | /* End XCConfigurationList section */ 542 | }; 543 | rootObject = 99AC12991C300B4C0079CE4C /* Project object */; 544 | } 545 | -------------------------------------------------------------------------------- /LSLColorPikerDemo/LSLColorPickerDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /LSLColorPikerDemo/LSLColorPickerView.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # Be sure to run `pod spec lint LSLColorPickerView.podspec' to ensure this is a 3 | # valid spec and to remove all comments including this before submitting the spec. 4 | # 5 | # To learn more about Podspec attributes see http://docs.cocoapods.org/specification.html 6 | # To see working Podspecs in the CocoaPods repo see https://github.com/CocoaPods/Specs/ 7 | # 8 | 9 | Pod::Spec.new do |s| 10 | 11 | s.name = "LSLColorPickerView" 12 | s.version = "1.0.0" 13 | s.summary = "一个很简洁实用的颜色选择器。" 14 | s.description = <<-DESC 15 | 学习Keynote,写了个属于自己的颜色选择器,用CALayer和其子类显示颜色条,用UIWindow自己封装成MenuController等等,代码高度内聚(一个类搞定),且简单实用。 16 | DESC 17 | 18 | s.homepage = "https://github.com/SilongLi/ColorPickerView" 19 | s.license = { :type => "MIT"} 20 | s.author = { "Bruce Li" => "lisilongios@163.com" } 21 | s.platform = :ios 22 | s.platform = :ios, "9.0" 23 | s.source = { :git => "https://github.com/SilongLi/ColorPickerView.git", :tag => "1.0.0" } 24 | s.source_files = "LSLColorPikerDemo/ColorPickerClass/*" 25 | s.requires_arc = true 26 | 27 | end 28 | -------------------------------------------------------------------------------- /LSLColorPikerDemo/LSLColorPikerDemo/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // LSLColorPickerDemo 4 | // 5 | // Created by lisilong on 15/12/27. 6 | // Copyright © 2015年 longshao. 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 | -------------------------------------------------------------------------------- /LSLColorPikerDemo/LSLColorPikerDemo/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // LSLColorPickerDemo 4 | // 5 | // Created by lisilong on 15/12/27. 6 | // Copyright © 2015年 longshao. 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 | - (void)applicationWillResignActive:(UIApplication *)application { 24 | // 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. 25 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 26 | } 27 | 28 | - (void)applicationDidEnterBackground:(UIApplication *)application { 29 | // 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. 30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 31 | } 32 | 33 | - (void)applicationWillEnterForeground:(UIApplication *)application { 34 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 35 | } 36 | 37 | - (void)applicationDidBecomeActive:(UIApplication *)application { 38 | // 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. 39 | } 40 | 41 | - (void)applicationWillTerminate:(UIApplication *)application { 42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /LSLColorPikerDemo/LSLColorPikerDemo/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /LSLColorPikerDemo/LSLColorPikerDemo/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 | 27 | 28 | -------------------------------------------------------------------------------- /LSLColorPikerDemo/LSLColorPikerDemo/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 | 22 | 23 | 34 | 35 | 36 | 37 | 38 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 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 | -------------------------------------------------------------------------------- /LSLColorPikerDemo/LSLColorPikerDemo/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 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 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /LSLColorPikerDemo/LSLColorPikerDemo/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // LSLColorPickerDemo 4 | // 5 | // Created by Bruce Li on 15/12/27. 6 | // Copyright © 2015年 longshao. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /LSLColorPikerDemo/LSLColorPikerDemo/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // LSLColorPickerDemo 4 | // 5 | // Created by Bruce Li on 15/12/27. 6 | // Copyright © 2015年 longshao. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "LSLHSBColorPickerView.h" 11 | 12 | @interface ViewController () 13 | 14 | @property (weak, nonatomic) IBOutlet UIView *currentSelectedColorPreview; 15 | @property (weak, nonatomic) IBOutlet UIView *contentView; 16 | 17 | @property (nonatomic, strong) UIColor *currentSelectedColor; 18 | @property (nonatomic, strong) LSLHSBColorPickerView *colorPickerView; 19 | 20 | @end 21 | 22 | @implementation ViewController 23 | 24 | - (void)viewDidLoad { 25 | [super viewDidLoad]; 26 | 27 | /// color picker view 28 | _colorPickerView = [[LSLHSBColorPickerView alloc] init]; 29 | [_contentView addSubview:_colorPickerView]; 30 | 31 | /// selected color preview 32 | _currentSelectedColorPreview.backgroundColor = _colorPickerView.preColor; 33 | 34 | /// selected color block 35 | __weak typeof(self) weakSelf = self; 36 | [_colorPickerView colorSelectedBlock:^(UIColor *color, BOOL isConfirm) { 37 | /// do something... 38 | /// 39 | weakSelf.currentSelectedColorPreview.backgroundColor = color; 40 | weakSelf.currentSelectedColor = color; 41 | }]; 42 | } 43 | 44 | - (void)viewWillLayoutSubviews { 45 | [super viewWillLayoutSubviews]; 46 | 47 | self.colorPickerView.frame = self.contentView.bounds; 48 | } 49 | 50 | #pragma mark - save or clean colors in archiver 51 | 52 | - (IBAction)saveSelectedColorToArchiver { 53 | if (self.currentSelectedColor) { 54 | [self.colorPickerView saveSelectedColorsToArchiver]; 55 | self.currentSelectedColor = nil; 56 | } 57 | } 58 | 59 | - (IBAction)cleanCache:(id)sender { 60 | [LSLHSBColorPickerView cleanSelectedColorsInArchiver]; 61 | } 62 | 63 | @end 64 | -------------------------------------------------------------------------------- /LSLColorPikerDemo/LSLColorPikerDemo/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // LSLColorPickerDemo 4 | // 5 | // Created by lisilong on 15/12/27. 6 | // Copyright © 2015年 longshao. 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 | -------------------------------------------------------------------------------- /LSLColorPikerDemo/LSLColorPikerDemoTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /LSLColorPikerDemo/LSLColorPikerDemoTests/LSLColorPikerDemoTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // LSLColorPickerDemoTests.m 3 | // LSLColorPickerDemoTests 4 | // 5 | // Created by lisilong on 15/12/27. 6 | // Copyright © 2015年 longshao. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface LSLColorPickerDemoTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation LSLColorPickerDemoTests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | // Put setup code here. This method is called before the invocation of each test method in the class. 20 | } 21 | 22 | - (void)tearDown { 23 | // Put teardown code here. This method is called after the invocation of each test method in the class. 24 | [super tearDown]; 25 | } 26 | 27 | - (void)testExample { 28 | // This is an example of a functional test case. 29 | // Use XCTAssert and related functions to verify your tests produce the correct results. 30 | } 31 | 32 | - (void)testPerformanceExample { 33 | // This is an example of a performance test case. 34 | [self measureBlock:^{ 35 | // Put the code you want to measure the time of here. 36 | }]; 37 | } 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /LSLColorPikerDemo/LSLColorPikerDemoUITests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /LSLColorPikerDemo/LSLColorPikerDemoUITests/LSLColorPikerDemoUITests.m: -------------------------------------------------------------------------------- 1 | // 2 | // LSLColorPickerDemoUITests.m 3 | // LSLColorPickerDemoUITests 4 | // 5 | // Created by lisilong on 15/12/27. 6 | // Copyright © 2015年 longshao. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface LSLColorPickerDemoUITests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation LSLColorPickerDemoUITests 16 | 17 | - (void)setUp { 18 | [super setUp]; 19 | 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | 22 | // In UI tests it is usually best to stop immediately when a failure occurs. 23 | self.continueAfterFailure = NO; 24 | // UI tests must launch the application that they test. Doing this in setup will make sure it happens for each test method. 25 | [[[XCUIApplication alloc] init] launch]; 26 | 27 | // In UI tests it’s important to set the initial state - such as interface orientation - required for your tests before they run. The setUp method is a good place to do this. 28 | } 29 | 30 | - (void)tearDown { 31 | // Put teardown code here. This method is called after the invocation of each test method in the class. 32 | [super tearDown]; 33 | } 34 | 35 | - (void)testExample { 36 | // Use recording to get started writing UI tests. 37 | // Use XCTAssert and related functions to verify your tests produce the correct results. 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ColorPickerView 2 | ##学习Keynote,写了个属于自己的颜色选择器,用CALayer和其子类显示颜色条,用UIWindow自己封装成MenuController等等,代码高度内聚(一个类搞定),且简单实用。 3 | 4 | 5 | ### CocoaPods集成 6 | 7 | ```objc 8 | pod 'LSLColorPickerView' 9 | 10 | ``` 11 | 12 | ### 一、实用说明: 13 | #### 1.实例化 14 | 15 | ```objc 16 | 17 | /// color picker view (size must be given) 18 | _colorPickerView = [[LSLHSBColorPickerView alloc] initWithFrame:_contentView.bounds]; 19 | [_contentView addSubview:_colorPickerView]; 20 | 21 | /// selected color preview 22 | _currentSelectedColorPreview.backgroundColor = _colorPickerView.preColor; 23 | 24 | /// selected color block 25 | __weak typeof(self) weakSelf = self; 26 | [_colorPickerView colorSelectedBlock:^(UIColor *color, BOOL isConfirm) { 27 | /// do something... 28 | /// 29 | weakSelf.currentSelectedColorPreview.backgroundColor = color; 30 | weakSelf.currentSelectedColor = color; 31 | }]; 32 | ``` 33 | 34 | #### 2.保存(或清空)本地文档(归档)中的数据 35 | 36 | ```objc 37 | #pragma mark - save or clean colors in archiver 38 | 39 | - (IBAction)saveSelectedColorToArchiver { 40 | if (self.currentSelectedColor) { 41 | [self.colorPickerView saveSelectedColorToArchiver]; 42 | self.currentSelectedColor = nil; 43 | } 44 | } 45 | 46 | - (IBAction)cleanCache:(id)sender { 47 | [LSLHSBColorPickerView cleanSelectedColorInArchiver]; 48 | } 49 | 50 | ``` 51 | 52 | ###二、GIF演示 53 | 54 | ![](https://github.com/SilongLi/ColorPickerView/raw/master/LSLColorPikerDemo/GIF/colorPickerView.gif) --------------------------------------------------------------------------------