├── LCStarRatingView ├── LCStarRatingView.h └── LCStarRatingView.m ├── LCStarRatingViewExample └── LCStarRatingViewExample │ ├── LCStarRatingViewExample.xcodeproj │ └── project.pbxproj │ └── LCStarRatingViewExample │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json │ ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard │ ├── Info.plist │ ├── ViewController.h │ ├── ViewController.m │ └── main.m ├── LICENSE └── README.md /LCStarRatingView/LCStarRatingView.h: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // _| _|_|_| 4 | // _| _| 5 | // _| _| 6 | // _| _| 7 | // _|_|_|_| _|_|_| 8 | // 9 | // 10 | // Copyright (c) 2016-2017, Licheng Guo. ( http://titm.me ) 11 | // http://github.com/titman 12 | // 13 | // 14 | // Permission is hereby granted, free of charge, to any person obtaining a 15 | // copy of this software and associated documentation files (the "Software"), 16 | // to deal in the Software without restriction, including without limitation 17 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 18 | // and/or sell copies of the Software, and to permit persons to whom the 19 | // Software is furnished to do so, subject to the following conditions: 20 | // 21 | // The above copyright notice and this permission notice shall be included in 22 | // all copies or substantial portions of the Software. 23 | // 24 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 25 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 26 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 27 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 28 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 29 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 30 | // IN THE SOFTWARE. 31 | // 32 | 33 | #import 34 | 35 | typedef NS_ENUM(NSInteger, LCStarRatingViewCountingType) { 36 | 37 | /** 38 | 0 1 2 3 4 5 39 | */ 40 | LCStarRatingViewCountingTypeInteger, 41 | /** 42 | 0.1 0.2 0.3 ... 1 1.1 ... 4.9 5 43 | */ 44 | LCStarRatingViewCountingTypeFloat, 45 | /** 46 | 0.5 1 1.5 2 2.5 3 3.5 ... 47 | */ 48 | LCStarRatingViewCountingTypeHalfCutting, 49 | }; 50 | 51 | typedef void(^LCStarRatingViewProgressDidChanedByUser)(CGFloat progress); 52 | 53 | @interface LCStarRatingView : UIView 54 | 55 | ///============================================================================= 56 | /// @name Configuring UI style 57 | ///============================================================================= 58 | IB_DESIGNABLE 59 | 60 | /** 61 | Default is LCStarRatingViewCountingTypeInteger . 62 | 63 | * LCStarRatingViewCountingTypeInteger [0, 1, 2, 3, 4, 5] 64 | * LCStarRatingViewCountingTypeFloat [0, 0.1, ... 0.4, ... 1, 1.1, ... 4.9, 5] 65 | * LCStarRatingViewCountingTypeHalfCutting [0, 0.5, 1, 1.5, 2, ...] 66 | */ 67 | @property(nonatomic, assign) LCStarRatingViewCountingType type; 68 | 69 | /** 70 | Default is 5.0 . 71 | */ 72 | @property(nonatomic, assign) IBInspectable CGFloat starMargin; 73 | 74 | /** 75 | Default is Yellow(255, 198, 0) . 76 | */ 77 | @property(nullable, nonatomic, strong) IBInspectable UIColor * starColor; 78 | 79 | /** 80 | Default is nil . 81 | */ 82 | @property(nullable, nonatomic, strong) IBInspectable UIColor * starBorderColor; 83 | 84 | /** 85 | Default is 0 . 86 | */ 87 | @property(nonatomic, assign) IBInspectable CGFloat starBorderWidth; 88 | 89 | /** 90 | Default is Light gray . 91 | */ 92 | @property(nullable, nonatomic, strong) IBInspectable UIColor * starPlaceHolderColor; 93 | 94 | /** 95 | Default is nil . 96 | */ 97 | @property(nullable, nonatomic, strong) IBInspectable UIColor * starPlaceHolderBorderColor; 98 | 99 | /** 100 | Default is 0 . 101 | */ 102 | @property(nonatomic, assign) IBInspectable CGFloat starPlaceHolderBorderWidth; 103 | 104 | ///============================================================================= 105 | /// @name Main attribute 106 | ///============================================================================= 107 | 108 | /** 109 | Default 3. this value pinned to [0, 5]. 110 | */ 111 | @property(nonatomic, assign) CGFloat progress; 112 | 113 | /** 114 | Default is YES. if NO, ignores touch events. 115 | */ 116 | @property(nonatomic, assign) BOOL enabled; 117 | 118 | 119 | /** 120 | Designated initializer. 121 | */ 122 | -(nonnull instancetype) init NS_DESIGNATED_INITIALIZER; 123 | -(nonnull instancetype) initWithFrame:(CGRect)frame NS_DESIGNATED_INITIALIZER; 124 | -(nonnull instancetype) initWithCoder:(nullable NSCoder *)aDecoder NS_DESIGNATED_INITIALIZER; 125 | 126 | 127 | ///============================================================================= 128 | /// @name Call back 129 | ///============================================================================= 130 | 131 | @property(nonatomic, copy) LCStarRatingViewProgressDidChanedByUser _Nullable progressDidChangedByUser; 132 | 133 | @end 134 | -------------------------------------------------------------------------------- /LCStarRatingView/LCStarRatingView.m: -------------------------------------------------------------------------------- 1 | // 2 | // 3 | // _| _|_|_| 4 | // _| _| 5 | // _| _| 6 | // _| _| 7 | // _|_|_|_| _|_|_| 8 | // 9 | // 10 | // Copyright (c) 2016-2017, Licheng Guo. ( http://titm.me ) 11 | // http://github.com/titman 12 | // 13 | // 14 | // Permission is hereby granted, free of charge, to any person obtaining a 15 | // copy of this software and associated documentation files (the "Software"), 16 | // to deal in the Software without restriction, including without limitation 17 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, 18 | // and/or sell copies of the Software, and to permit persons to whom the 19 | // Software is furnished to do so, subject to the following conditions: 20 | // 21 | // The above copyright notice and this permission notice shall be included in 22 | // all copies or substantial portions of the Software. 23 | // 24 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 25 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 26 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 27 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 28 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 29 | // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 30 | // IN THE SOFTWARE. 31 | // 32 | 33 | #import "LCStarRatingView.h" 34 | 35 | 36 | 37 | @interface __LCStar : UIView 38 | 39 | @property(nullable, nonatomic, strong) UIColor * starColor; 40 | @property(nullable, nonatomic, strong) UIColor * starBorderColor; 41 | @property(nullable, nonatomic, strong) UIColor * starImage; 42 | 43 | @property(nonatomic, assign) CGFloat starBorderWidth; 44 | 45 | @property(nonatomic, assign) CGFloat value; 46 | 47 | @end 48 | 49 | @implementation __LCStar 50 | 51 | -(instancetype) init 52 | { 53 | if(self = [super initWithFrame:CGRectZero]){ 54 | 55 | [self initSelf]; 56 | } 57 | 58 | return self; 59 | } 60 | 61 | -(instancetype) initWithFrame:(CGRect)frame 62 | { 63 | if(self = [super initWithFrame:frame]){ 64 | 65 | [self initSelf]; 66 | } 67 | 68 | return self; 69 | } 70 | 71 | -(instancetype) initWithCoder:(NSCoder *)aDecoder 72 | { 73 | if(self = [super initWithCoder:aDecoder]){ 74 | 75 | [self initSelf]; 76 | } 77 | 78 | return self; 79 | } 80 | 81 | -(void) initSelf 82 | { 83 | self.value = 1; 84 | self.starColor = [UIColor yellowColor]; 85 | self.starBorderColor = [UIColor clearColor]; 86 | self.starBorderWidth = 0; 87 | 88 | self.opaque = NO; 89 | } 90 | 91 | -(void) setValue:(CGFloat)value 92 | { 93 | _value = value; 94 | 95 | [self setNeedsDisplay]; 96 | } 97 | 98 | -(void) setStarColor:(UIColor *)starColor 99 | { 100 | _starColor = starColor; 101 | 102 | [self setNeedsDisplay]; 103 | } 104 | 105 | -(void) setStarBorderColor:(UIColor *)starBorderColor 106 | { 107 | _starBorderColor = starBorderColor; 108 | 109 | [self setNeedsDisplay]; 110 | } 111 | 112 | -(void) setStarBorderWidth:(CGFloat)starBorderWidth 113 | { 114 | _starBorderWidth = starBorderWidth; 115 | 116 | [self setNeedsDisplay]; 117 | } 118 | 119 | -(void) setFrame:(CGRect)frame 120 | { 121 | [super setFrame:frame]; 122 | 123 | [self setNeedsDisplay]; 124 | } 125 | 126 | -(void) setStarImage:(UIColor *)starImage 127 | { 128 | _starImage = starImage; 129 | 130 | [self setNeedsDisplay]; 131 | } 132 | 133 | - (void)drawRect:(CGRect)rect 134 | { 135 | if (self.starImage) { 136 | 137 | [super drawRect:rect]; 138 | return; 139 | } 140 | 141 | CGFloat th = M_PI / 180.; 142 | 143 | CGFloat x = self.frame.size.width / 2; 144 | CGFloat y = self.frame.size.height / 2; 145 | 146 | CGFloat radius = x < y ? x:y; 147 | 148 | CGFloat centerX = rect.size.width / 2; 149 | CGFloat centerY = rect.size.height / 2; 150 | 151 | CGFloat r0 = radius * sin(18 * th)/cos(36 * th); 152 | CGFloat x1[5] = {0},y1[5]={0},x2[5]={0},y2[5]={0}; 153 | 154 | for (int i = 0; i < 5; i ++) 155 | { 156 | x1[i] = centerX + radius * cos((90 + i * 72) * th); 157 | y1[i] =centerY - radius * sin((90 + i * 72) * th); 158 | 159 | x2[i] = centerX + r0 * cos((54 + i * 72) * th); 160 | y2[i] = centerY - r0 * sin((54 + i * 72) * th); 161 | } 162 | 163 | CGContextRef context = UIGraphicsGetCurrentContext(); 164 | 165 | CGMutablePathRef startPath = CGPathCreateMutable(); 166 | CGPathMoveToPoint(startPath, NULL, x1[0], y1[0]); 167 | 168 | CGContextSetLineWidth(context, self.starBorderWidth); 169 | CGContextSetLineCap(context, kCGLineCapButt); 170 | 171 | for (int i = 1; i < 5; i ++) { 172 | 173 | CGPathAddLineToPoint(startPath, NULL, x2[i], y2[i]); 174 | CGPathAddLineToPoint(startPath, NULL, x1[i], y1[i]); 175 | } 176 | 177 | CGPathAddLineToPoint(startPath, NULL, x2[0], y2[0]); 178 | CGPathCloseSubpath(startPath); 179 | 180 | 181 | CGContextAddPath(context, startPath); 182 | 183 | CGContextSetFillColorWithColor(context, self.starColor.CGColor); 184 | 185 | CGContextSetStrokeColorWithColor(context, self.starBorderColor.CGColor); 186 | CGContextStrokePath(context); 187 | 188 | CGRect range = CGRectMake(x1[1], 0, (x1[4] - x1[1]) * self.value , y1[2]); 189 | 190 | CGContextAddPath(context, startPath); 191 | CGContextClip(context); 192 | CGContextFillRect(context, range); 193 | 194 | 195 | CFRelease(startPath); 196 | } 197 | 198 | 199 | @end 200 | 201 | @interface LCStarRatingView () 202 | 203 | @property(nullable, nonatomic, strong) UIImageView * progressImageView; 204 | @property(nullable, nonatomic, strong) UIImageView * backgroundImageView; 205 | 206 | @end 207 | 208 | @implementation LCStarRatingView 209 | 210 | #pragma mark - Designated initializer 211 | #pragma mark - 212 | 213 | -(instancetype) init 214 | { 215 | if(self = [super initWithFrame:CGRectZero]){ 216 | 217 | [self initSelf]; 218 | } 219 | 220 | return self; 221 | } 222 | 223 | -(instancetype) initWithFrame:(CGRect)frame 224 | { 225 | if(self = [super initWithFrame:frame]){ 226 | 227 | [self initSelf]; 228 | } 229 | 230 | return self; 231 | } 232 | 233 | -(instancetype) initWithCoder:(NSCoder *)aDecoder 234 | { 235 | if(self = [super initWithCoder:aDecoder]){ 236 | 237 | [self initSelf]; 238 | } 239 | 240 | return self; 241 | } 242 | 243 | -(void) initSelf 244 | { 245 | self.starMargin = 5; 246 | self.starColor = [UIColor colorWithRed:255./255. green:198./255. blue:0 alpha:1]; 247 | self.starBorderColor = [UIColor clearColor]; 248 | self.starBorderWidth = 0; 249 | self.starPlaceHolderColor = [UIColor lightGrayColor]; 250 | self.starPlaceHolderBorderColor = [UIColor clearColor]; 251 | self.starPlaceHolderBorderWidth = 0; 252 | 253 | self.progress = 3; 254 | 255 | self.backgroundImageView = [[UIImageView alloc] init]; 256 | self.backgroundImageView.frame = self.bounds; 257 | self.backgroundImageView.userInteractionEnabled = YES; 258 | self.backgroundImageView.contentMode = UIViewContentModeLeft; 259 | self.backgroundImageView.clipsToBounds = YES; 260 | [self addSubview:self.backgroundImageView]; 261 | 262 | 263 | self.progressImageView = [[UIImageView alloc] init]; 264 | self.progressImageView.frame = self.bounds; 265 | self.progressImageView.contentMode = UIViewContentModeLeft; 266 | self.progressImageView.clipsToBounds = YES; 267 | [self addSubview:self.progressImageView]; 268 | 269 | 270 | UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction:)]; 271 | [self.backgroundImageView addGestureRecognizer:tap]; 272 | 273 | 274 | UIPanGestureRecognizer * pan = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panAction:)]; 275 | [self.backgroundImageView addGestureRecognizer:pan]; 276 | 277 | 278 | 279 | [self loadStars]; 280 | } 281 | 282 | #pragma mark - Action 283 | #pragma mark - 284 | 285 | -(void) tapAction:(UITapGestureRecognizer *)tap 286 | { 287 | CGPoint tapPoint = [tap locationInView:self.backgroundImageView]; 288 | 289 | CGFloat progress = 5. / self.frame.size.width * tapPoint.x; 290 | 291 | self.progress = progress; 292 | 293 | if (self.progressDidChangedByUser) { 294 | self.progressDidChangedByUser(self.progress); 295 | } 296 | } 297 | 298 | -(void) panAction:(UIPanGestureRecognizer *)pan 299 | { 300 | CGPoint panPoint = [pan locationInView:self.backgroundImageView]; 301 | 302 | CGFloat progress = 5. / self.frame.size.width * panPoint.x; 303 | 304 | self.progress = progress; 305 | 306 | if (self.progressDidChangedByUser) { 307 | self.progressDidChangedByUser(self.progress); 308 | } 309 | } 310 | 311 | -(void) loadStars 312 | { 313 | [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(loadStarsDelay) object:nil]; 314 | [self performSelector:@selector(loadStarsDelay) withObject:nil afterDelay:0]; 315 | } 316 | 317 | -(void) loadStarsDelay 318 | { 319 | self.backgroundImageView.frame = self.bounds; 320 | self.progressImageView.frame = self.bounds; 321 | self.progress = self.progress; 322 | 323 | 324 | CGFloat starWidth = (self.frame.size.width - self.starMargin * 4) / 5; 325 | 326 | UIView * backgroundCache = [[UIImageView alloc] init]; 327 | backgroundCache.frame = self.bounds; 328 | 329 | // Background. 330 | for (NSInteger i = 0; i < 5; i++) { 331 | 332 | __LCStar * star = [[__LCStar alloc] init]; 333 | star.frame = CGRectMake(starWidth * i + self.starMargin * i, 0, starWidth, self.frame.size.height); 334 | star.starColor = self.starPlaceHolderColor; 335 | star.starBorderColor = self.starPlaceHolderBorderColor; 336 | star.starBorderWidth = self.starPlaceHolderBorderWidth; 337 | 338 | [backgroundCache addSubview:star]; 339 | } 340 | 341 | self.backgroundImageView.image = [self convertViewToImage:backgroundCache]; 342 | 343 | 344 | UIView * starCache = [[UIImageView alloc] init]; 345 | starCache.frame = self.bounds; 346 | 347 | // Foreground. 348 | for (NSInteger i = 0; i < 5; i++) { 349 | 350 | __LCStar * star = [[__LCStar alloc] init]; 351 | star.frame = CGRectMake(starWidth * i + self.starMargin * i, 0, starWidth, self.frame.size.height); 352 | star.starColor = self.starColor; 353 | star.starBorderColor = self.starBorderColor; 354 | star.starBorderWidth = self.starBorderWidth; 355 | 356 | [starCache addSubview:star]; 357 | } 358 | 359 | self.progressImageView.image = [self convertViewToImage:starCache]; 360 | } 361 | 362 | -(UIImage *) convertViewToImage:(UIView *)view 363 | { 364 | UIGraphicsBeginImageContextWithOptions(view.frame.size, NO, [UIScreen mainScreen].scale); 365 | 366 | [view.layer renderInContext:UIGraphicsGetCurrentContext()]; 367 | 368 | UIImage * image = UIGraphicsGetImageFromCurrentImageContext(); 369 | 370 | UIGraphicsEndImageContext(); 371 | 372 | return image; 373 | } 374 | 375 | 376 | #pragma mark - Overwrite 377 | #pragma mark - 378 | 379 | -(void) dealloc 380 | { 381 | [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(loadStarsDelay) object:nil]; 382 | } 383 | 384 | -(void) removeFromSuperview 385 | { 386 | [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(loadStarsDelay) object:nil]; 387 | 388 | [super removeFromSuperview]; 389 | } 390 | 391 | -(void) setEnabled:(BOOL)enabled 392 | { 393 | _enabled = enabled; 394 | 395 | for (UIGestureRecognizer * ges in self.backgroundImageView.gestureRecognizers) { 396 | 397 | ges.enabled = enabled; 398 | } 399 | } 400 | 401 | -(void) setStarMargin:(CGFloat)starMargin 402 | { 403 | _starMargin = starMargin; 404 | 405 | [self loadStars]; 406 | } 407 | 408 | -(void) setStarColor:(UIColor *)starColor 409 | { 410 | _starColor = starColor; 411 | 412 | [self loadStars]; 413 | } 414 | 415 | -(void) setStarBorderColor:(UIColor *)starBorderColor 416 | { 417 | _starBorderColor = starBorderColor; 418 | 419 | [self loadStars]; 420 | } 421 | 422 | -(void) setStarBorderWidth:(CGFloat)starBorderWidth 423 | { 424 | _starBorderWidth = starBorderWidth; 425 | 426 | [self loadStars]; 427 | } 428 | 429 | -(void) setStarPlaceHolderColor:(UIColor *)starPlaceHolderColor 430 | { 431 | _starPlaceHolderColor = starPlaceHolderColor; 432 | 433 | [self loadStars]; 434 | } 435 | 436 | -(void) setStarPlaceHolderBorderColor:(UIColor *)starPlaceHolderBorderColor 437 | { 438 | _starPlaceHolderBorderColor = starPlaceHolderBorderColor; 439 | 440 | [self loadStars]; 441 | } 442 | 443 | -(void) setStarPlaceHolderBorderWidth:(CGFloat)starPlaceHolderBorderWidth 444 | { 445 | _starPlaceHolderBorderWidth = starPlaceHolderBorderWidth; 446 | 447 | [self loadStars]; 448 | } 449 | 450 | -(void) setFrame:(CGRect)frame 451 | { 452 | [super setFrame:frame]; 453 | 454 | [self loadStars]; 455 | } 456 | 457 | -(void) setType:(LCStarRatingViewCountingType)type 458 | { 459 | _type = type; 460 | 461 | self.progress = self.progress; 462 | } 463 | 464 | -(void) setProgress:(CGFloat)progress 465 | { 466 | if (progress > 5. || progress < 0) { 467 | 468 | NSLog(@"Progress could not greater than 5.0"); 469 | 470 | if (progress > 5.) progress = 5.; 471 | else if(progress < 0) progress = 0; 472 | } 473 | 474 | switch (self.type) { 475 | case LCStarRatingViewCountingTypeInteger: 476 | progress = roundf(progress); 477 | break; 478 | case LCStarRatingViewCountingTypeFloat: 479 | break; 480 | case LCStarRatingViewCountingTypeHalfCutting: 481 | 482 | #define HALF_CUTTING(number) else if (progress > number && progress <= number + 0.5) progress = number + 0.25 483 | if (progress <= 0.25) progress = 0; 484 | HALF_CUTTING(0.25); 485 | HALF_CUTTING(0.75); 486 | HALF_CUTTING(1.25); 487 | HALF_CUTTING(1.75); 488 | HALF_CUTTING(2.25); 489 | HALF_CUTTING(2.75); 490 | HALF_CUTTING(3.25); 491 | HALF_CUTTING(3.75); 492 | HALF_CUTTING(4.25); 493 | HALF_CUTTING(4.75); 494 | break; 495 | } 496 | 497 | _progress = progress; 498 | 499 | self.progressImageView.frame = CGRectMake(0, 0, self.frame.size.width / 5. * self.progress, self.frame.size.height); 500 | } 501 | 502 | 503 | @end 504 | 505 | 506 | 507 | -------------------------------------------------------------------------------- /LCStarRatingViewExample/LCStarRatingViewExample/LCStarRatingViewExample.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 134516EB1E091E6600E7962B /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 134516EA1E091E6600E7962B /* main.m */; }; 11 | 134516EE1E091E6600E7962B /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 134516ED1E091E6600E7962B /* AppDelegate.m */; }; 12 | 134516F11E091E6600E7962B /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 134516F01E091E6600E7962B /* ViewController.m */; }; 13 | 134516F41E091E6600E7962B /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 134516F21E091E6600E7962B /* Main.storyboard */; }; 14 | 134516F61E091E6600E7962B /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 134516F51E091E6600E7962B /* Assets.xcassets */; }; 15 | 134516F91E091E6600E7962B /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 134516F71E091E6600E7962B /* LaunchScreen.storyboard */; }; 16 | 134517031E091EAE00E7962B /* LCStarRatingView.m in Sources */ = {isa = PBXBuildFile; fileRef = 134517021E091EAE00E7962B /* LCStarRatingView.m */; }; 17 | /* End PBXBuildFile section */ 18 | 19 | /* Begin PBXFileReference section */ 20 | 134516E61E091E6600E7962B /* LCStarRatingViewExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = LCStarRatingViewExample.app; sourceTree = BUILT_PRODUCTS_DIR; }; 21 | 134516EA1E091E6600E7962B /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 22 | 134516EC1E091E6600E7962B /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 23 | 134516ED1E091E6600E7962B /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 24 | 134516EF1E091E6600E7962B /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 25 | 134516F01E091E6600E7962B /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 26 | 134516F31E091E6600E7962B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 27 | 134516F51E091E6600E7962B /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 28 | 134516F81E091E6600E7962B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 29 | 134516FA1E091E6600E7962B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 30 | 134517011E091EAE00E7962B /* LCStarRatingView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LCStarRatingView.h; sourceTree = ""; }; 31 | 134517021E091EAE00E7962B /* LCStarRatingView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = LCStarRatingView.m; sourceTree = ""; }; 32 | /* End PBXFileReference section */ 33 | 34 | /* Begin PBXFrameworksBuildPhase section */ 35 | 134516E31E091E6600E7962B /* Frameworks */ = { 36 | isa = PBXFrameworksBuildPhase; 37 | buildActionMask = 2147483647; 38 | files = ( 39 | ); 40 | runOnlyForDeploymentPostprocessing = 0; 41 | }; 42 | /* End PBXFrameworksBuildPhase section */ 43 | 44 | /* Begin PBXGroup section */ 45 | 134516DD1E091E6600E7962B = { 46 | isa = PBXGroup; 47 | children = ( 48 | 134516E81E091E6600E7962B /* LCStarRatingViewExample */, 49 | 134516E71E091E6600E7962B /* Products */, 50 | ); 51 | sourceTree = ""; 52 | }; 53 | 134516E71E091E6600E7962B /* Products */ = { 54 | isa = PBXGroup; 55 | children = ( 56 | 134516E61E091E6600E7962B /* LCStarRatingViewExample.app */, 57 | ); 58 | name = Products; 59 | sourceTree = ""; 60 | }; 61 | 134516E81E091E6600E7962B /* LCStarRatingViewExample */ = { 62 | isa = PBXGroup; 63 | children = ( 64 | 134516EC1E091E6600E7962B /* AppDelegate.h */, 65 | 134516ED1E091E6600E7962B /* AppDelegate.m */, 66 | 134517001E091EAE00E7962B /* LCStarRatingView */, 67 | 134516EF1E091E6600E7962B /* ViewController.h */, 68 | 134516F01E091E6600E7962B /* ViewController.m */, 69 | 134516F21E091E6600E7962B /* Main.storyboard */, 70 | 134516F51E091E6600E7962B /* Assets.xcassets */, 71 | 134516F71E091E6600E7962B /* LaunchScreen.storyboard */, 72 | 134516FA1E091E6600E7962B /* Info.plist */, 73 | 134516E91E091E6600E7962B /* Supporting Files */, 74 | ); 75 | path = LCStarRatingViewExample; 76 | sourceTree = ""; 77 | }; 78 | 134516E91E091E6600E7962B /* Supporting Files */ = { 79 | isa = PBXGroup; 80 | children = ( 81 | 134516EA1E091E6600E7962B /* main.m */, 82 | ); 83 | name = "Supporting Files"; 84 | sourceTree = ""; 85 | }; 86 | 134517001E091EAE00E7962B /* LCStarRatingView */ = { 87 | isa = PBXGroup; 88 | children = ( 89 | 134517011E091EAE00E7962B /* LCStarRatingView.h */, 90 | 134517021E091EAE00E7962B /* LCStarRatingView.m */, 91 | ); 92 | name = LCStarRatingView; 93 | path = ../../../LCStarRatingView; 94 | sourceTree = ""; 95 | }; 96 | /* End PBXGroup section */ 97 | 98 | /* Begin PBXNativeTarget section */ 99 | 134516E51E091E6600E7962B /* LCStarRatingViewExample */ = { 100 | isa = PBXNativeTarget; 101 | buildConfigurationList = 134516FD1E091E6600E7962B /* Build configuration list for PBXNativeTarget "LCStarRatingViewExample" */; 102 | buildPhases = ( 103 | 134516E21E091E6600E7962B /* Sources */, 104 | 134516E31E091E6600E7962B /* Frameworks */, 105 | 134516E41E091E6600E7962B /* Resources */, 106 | ); 107 | buildRules = ( 108 | ); 109 | dependencies = ( 110 | ); 111 | name = LCStarRatingViewExample; 112 | productName = LCStarRatingViewExample; 113 | productReference = 134516E61E091E6600E7962B /* LCStarRatingViewExample.app */; 114 | productType = "com.apple.product-type.application"; 115 | }; 116 | /* End PBXNativeTarget section */ 117 | 118 | /* Begin PBXProject section */ 119 | 134516DE1E091E6600E7962B /* Project object */ = { 120 | isa = PBXProject; 121 | attributes = { 122 | LastUpgradeCheck = 0810; 123 | ORGANIZATIONNAME = titman; 124 | TargetAttributes = { 125 | 134516E51E091E6600E7962B = { 126 | CreatedOnToolsVersion = 8.1; 127 | ProvisioningStyle = Automatic; 128 | }; 129 | }; 130 | }; 131 | buildConfigurationList = 134516E11E091E6600E7962B /* Build configuration list for PBXProject "LCStarRatingViewExample" */; 132 | compatibilityVersion = "Xcode 3.2"; 133 | developmentRegion = English; 134 | hasScannedForEncodings = 0; 135 | knownRegions = ( 136 | en, 137 | Base, 138 | ); 139 | mainGroup = 134516DD1E091E6600E7962B; 140 | productRefGroup = 134516E71E091E6600E7962B /* Products */; 141 | projectDirPath = ""; 142 | projectRoot = ""; 143 | targets = ( 144 | 134516E51E091E6600E7962B /* LCStarRatingViewExample */, 145 | ); 146 | }; 147 | /* End PBXProject section */ 148 | 149 | /* Begin PBXResourcesBuildPhase section */ 150 | 134516E41E091E6600E7962B /* Resources */ = { 151 | isa = PBXResourcesBuildPhase; 152 | buildActionMask = 2147483647; 153 | files = ( 154 | 134516F91E091E6600E7962B /* LaunchScreen.storyboard in Resources */, 155 | 134516F61E091E6600E7962B /* Assets.xcassets in Resources */, 156 | 134516F41E091E6600E7962B /* Main.storyboard in Resources */, 157 | ); 158 | runOnlyForDeploymentPostprocessing = 0; 159 | }; 160 | /* End PBXResourcesBuildPhase section */ 161 | 162 | /* Begin PBXSourcesBuildPhase section */ 163 | 134516E21E091E6600E7962B /* Sources */ = { 164 | isa = PBXSourcesBuildPhase; 165 | buildActionMask = 2147483647; 166 | files = ( 167 | 134516F11E091E6600E7962B /* ViewController.m in Sources */, 168 | 134516EE1E091E6600E7962B /* AppDelegate.m in Sources */, 169 | 134517031E091EAE00E7962B /* LCStarRatingView.m in Sources */, 170 | 134516EB1E091E6600E7962B /* main.m in Sources */, 171 | ); 172 | runOnlyForDeploymentPostprocessing = 0; 173 | }; 174 | /* End PBXSourcesBuildPhase section */ 175 | 176 | /* Begin PBXVariantGroup section */ 177 | 134516F21E091E6600E7962B /* Main.storyboard */ = { 178 | isa = PBXVariantGroup; 179 | children = ( 180 | 134516F31E091E6600E7962B /* Base */, 181 | ); 182 | name = Main.storyboard; 183 | sourceTree = ""; 184 | }; 185 | 134516F71E091E6600E7962B /* LaunchScreen.storyboard */ = { 186 | isa = PBXVariantGroup; 187 | children = ( 188 | 134516F81E091E6600E7962B /* Base */, 189 | ); 190 | name = LaunchScreen.storyboard; 191 | sourceTree = ""; 192 | }; 193 | /* End PBXVariantGroup section */ 194 | 195 | /* Begin XCBuildConfiguration section */ 196 | 134516FB1E091E6600E7962B /* Debug */ = { 197 | isa = XCBuildConfiguration; 198 | buildSettings = { 199 | ALWAYS_SEARCH_USER_PATHS = NO; 200 | CLANG_ANALYZER_NONNULL = YES; 201 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 202 | CLANG_CXX_LIBRARY = "libc++"; 203 | CLANG_ENABLE_MODULES = YES; 204 | CLANG_ENABLE_OBJC_ARC = YES; 205 | CLANG_WARN_BOOL_CONVERSION = YES; 206 | CLANG_WARN_CONSTANT_CONVERSION = YES; 207 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 208 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 209 | CLANG_WARN_EMPTY_BODY = YES; 210 | CLANG_WARN_ENUM_CONVERSION = YES; 211 | CLANG_WARN_INFINITE_RECURSION = YES; 212 | CLANG_WARN_INT_CONVERSION = YES; 213 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 214 | CLANG_WARN_SUSPICIOUS_MOVES = YES; 215 | CLANG_WARN_UNREACHABLE_CODE = YES; 216 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 217 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 218 | COPY_PHASE_STRIP = NO; 219 | DEBUG_INFORMATION_FORMAT = dwarf; 220 | ENABLE_STRICT_OBJC_MSGSEND = YES; 221 | ENABLE_TESTABILITY = YES; 222 | GCC_C_LANGUAGE_STANDARD = gnu99; 223 | GCC_DYNAMIC_NO_PIC = NO; 224 | GCC_NO_COMMON_BLOCKS = YES; 225 | GCC_OPTIMIZATION_LEVEL = 0; 226 | GCC_PREPROCESSOR_DEFINITIONS = ( 227 | "DEBUG=1", 228 | "$(inherited)", 229 | ); 230 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 231 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 232 | GCC_WARN_UNDECLARED_SELECTOR = YES; 233 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 234 | GCC_WARN_UNUSED_FUNCTION = YES; 235 | GCC_WARN_UNUSED_VARIABLE = YES; 236 | IPHONEOS_DEPLOYMENT_TARGET = 10.1; 237 | MTL_ENABLE_DEBUG_INFO = YES; 238 | ONLY_ACTIVE_ARCH = YES; 239 | SDKROOT = iphoneos; 240 | }; 241 | name = Debug; 242 | }; 243 | 134516FC1E091E6600E7962B /* Release */ = { 244 | isa = XCBuildConfiguration; 245 | buildSettings = { 246 | ALWAYS_SEARCH_USER_PATHS = NO; 247 | CLANG_ANALYZER_NONNULL = YES; 248 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 249 | CLANG_CXX_LIBRARY = "libc++"; 250 | CLANG_ENABLE_MODULES = YES; 251 | CLANG_ENABLE_OBJC_ARC = YES; 252 | CLANG_WARN_BOOL_CONVERSION = YES; 253 | CLANG_WARN_CONSTANT_CONVERSION = YES; 254 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 255 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 256 | CLANG_WARN_EMPTY_BODY = YES; 257 | CLANG_WARN_ENUM_CONVERSION = YES; 258 | CLANG_WARN_INFINITE_RECURSION = YES; 259 | CLANG_WARN_INT_CONVERSION = YES; 260 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 261 | CLANG_WARN_SUSPICIOUS_MOVES = YES; 262 | CLANG_WARN_UNREACHABLE_CODE = YES; 263 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 264 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 265 | COPY_PHASE_STRIP = NO; 266 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 267 | ENABLE_NS_ASSERTIONS = NO; 268 | ENABLE_STRICT_OBJC_MSGSEND = YES; 269 | GCC_C_LANGUAGE_STANDARD = gnu99; 270 | GCC_NO_COMMON_BLOCKS = YES; 271 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 272 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 273 | GCC_WARN_UNDECLARED_SELECTOR = YES; 274 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 275 | GCC_WARN_UNUSED_FUNCTION = YES; 276 | GCC_WARN_UNUSED_VARIABLE = YES; 277 | IPHONEOS_DEPLOYMENT_TARGET = 10.1; 278 | MTL_ENABLE_DEBUG_INFO = NO; 279 | SDKROOT = iphoneos; 280 | VALIDATE_PRODUCT = YES; 281 | }; 282 | name = Release; 283 | }; 284 | 134516FE1E091E6600E7962B /* Debug */ = { 285 | isa = XCBuildConfiguration; 286 | buildSettings = { 287 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 288 | INFOPLIST_FILE = LCStarRatingViewExample/Info.plist; 289 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 290 | PRODUCT_BUNDLE_IDENTIFIER = titman.LCStarRatingViewExample; 291 | PRODUCT_NAME = "$(TARGET_NAME)"; 292 | }; 293 | name = Debug; 294 | }; 295 | 134516FF1E091E6600E7962B /* Release */ = { 296 | isa = XCBuildConfiguration; 297 | buildSettings = { 298 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 299 | INFOPLIST_FILE = LCStarRatingViewExample/Info.plist; 300 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 301 | PRODUCT_BUNDLE_IDENTIFIER = titman.LCStarRatingViewExample; 302 | PRODUCT_NAME = "$(TARGET_NAME)"; 303 | }; 304 | name = Release; 305 | }; 306 | /* End XCBuildConfiguration section */ 307 | 308 | /* Begin XCConfigurationList section */ 309 | 134516E11E091E6600E7962B /* Build configuration list for PBXProject "LCStarRatingViewExample" */ = { 310 | isa = XCConfigurationList; 311 | buildConfigurations = ( 312 | 134516FB1E091E6600E7962B /* Debug */, 313 | 134516FC1E091E6600E7962B /* Release */, 314 | ); 315 | defaultConfigurationIsVisible = 0; 316 | defaultConfigurationName = Release; 317 | }; 318 | 134516FD1E091E6600E7962B /* Build configuration list for PBXNativeTarget "LCStarRatingViewExample" */ = { 319 | isa = XCConfigurationList; 320 | buildConfigurations = ( 321 | 134516FE1E091E6600E7962B /* Debug */, 322 | 134516FF1E091E6600E7962B /* Release */, 323 | ); 324 | defaultConfigurationIsVisible = 0; 325 | }; 326 | /* End XCConfigurationList section */ 327 | }; 328 | rootObject = 134516DE1E091E6600E7962B /* Project object */; 329 | } 330 | -------------------------------------------------------------------------------- /LCStarRatingViewExample/LCStarRatingViewExample/LCStarRatingViewExample/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // LCStarRatingViewExample 4 | // 5 | // Created by Guolicheng on 2016/12/20. 6 | // Copyright © 2016年 titman. 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 | -------------------------------------------------------------------------------- /LCStarRatingViewExample/LCStarRatingViewExample/LCStarRatingViewExample/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // LCStarRatingViewExample 4 | // 5 | // Created by Guolicheng on 2016/12/20. 6 | // Copyright © 2016年 titman. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | 24 | - (void)applicationWillResignActive:(UIApplication *)application { 25 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 26 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 27 | } 28 | 29 | 30 | - (void)applicationDidEnterBackground:(UIApplication *)application { 31 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 32 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 33 | } 34 | 35 | 36 | - (void)applicationWillEnterForeground:(UIApplication *)application { 37 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 38 | } 39 | 40 | 41 | - (void)applicationDidBecomeActive:(UIApplication *)application { 42 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 43 | } 44 | 45 | 46 | - (void)applicationWillTerminate:(UIApplication *)application { 47 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 48 | } 49 | 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /LCStarRatingViewExample/LCStarRatingViewExample/LCStarRatingViewExample/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 | } -------------------------------------------------------------------------------- /LCStarRatingViewExample/LCStarRatingViewExample/LCStarRatingViewExample/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 | -------------------------------------------------------------------------------- /LCStarRatingViewExample/LCStarRatingViewExample/LCStarRatingViewExample/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 | 24 | 32 | 40 | 48 | 55 | 62 | 69 | 77 | 85 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | -------------------------------------------------------------------------------- /LCStarRatingViewExample/LCStarRatingViewExample/LCStarRatingViewExample/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 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /LCStarRatingViewExample/LCStarRatingViewExample/LCStarRatingViewExample/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // LCStarRatingViewExample 4 | // 5 | // Created by Guolicheng on 2016/12/20. 6 | // Copyright © 2016年 titman. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | @property(strong) IBOutlet UIButton * starColorButton; 14 | @property(strong) IBOutlet UIButton * starBorderColorButton; 15 | @property(strong) IBOutlet UIButton * starBorderWithButton; 16 | @property(strong) IBOutlet UIButton * starPlaceHolderColorButton; 17 | @property(strong) IBOutlet UIButton * starPlaceHolderBorderColorButton; 18 | @property(strong) IBOutlet UIButton * starPlaceHolderBorderWidthButton; 19 | 20 | @property(strong) IBOutlet UISlider * slider; 21 | 22 | @property(strong) IBOutlet UISegmentedControl * segment; 23 | 24 | @end 25 | 26 | -------------------------------------------------------------------------------- /LCStarRatingViewExample/LCStarRatingViewExample/LCStarRatingViewExample/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // LCStarRatingViewExample 4 | // 5 | // Created by Guolicheng on 2016/12/20. 6 | // Copyright © 2016年 titman. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "LCStarRatingView.h" 11 | 12 | @interface ViewController () 13 | 14 | @property(nonatomic, strong) IBOutlet LCStarRatingView * ratingView; 15 | 16 | @end 17 | 18 | @implementation ViewController 19 | 20 | - (void)viewDidLoad { 21 | [super viewDidLoad]; 22 | // Do any additional setup after loading the view, typically from a nib. 23 | 24 | self.slider.continuous = NO; 25 | 26 | 27 | // self.ratingView = [[LCStarRatingView alloc] init]; 28 | // self.ratingView.frame = CGRectMake(100, 100, 200, 200); 29 | // 30 | // [self.view addSubview:self.ratingView]; 31 | 32 | 33 | __weak ViewController * vc = self; 34 | 35 | self.ratingView.progressDidChangedByUser = ^(CGFloat progress){ 36 | 37 | NSLog(@"progressDidChangedByUser : %@", @(progress)); 38 | vc.slider.value = progress; 39 | }; 40 | } 41 | 42 | -(UIColor *) randomColor 43 | { 44 | return [UIColor colorWithRed:arc4random_uniform(255)/255.0 green:arc4random_uniform(255)/255.0 blue:arc4random_uniform(255)/255.0 alpha:1]; 45 | } 46 | 47 | -(CGFloat) increasingWidth 48 | { 49 | static CGFloat width = -1; 50 | 51 | if (width == 5) width = -1; 52 | 53 | width += 1; 54 | 55 | return width; 56 | } 57 | 58 | -(IBAction)setColor:(UIButton *)sender 59 | { 60 | if (sender.tag == 0) self.ratingView.starColor = self.randomColor; 61 | else self.ratingView.starPlaceHolderColor = self.randomColor; 62 | } 63 | 64 | -(IBAction)setBorderColor:(UIButton *)sender 65 | { 66 | if (sender.tag == 0) self.ratingView.starBorderColor = self.randomColor; 67 | else self.ratingView.starPlaceHolderBorderColor = self.randomColor; 68 | } 69 | 70 | -(IBAction)setBorderWidth:(UIButton *)sender 71 | { 72 | if (sender.tag == 0) self.ratingView.starBorderWidth = self.increasingWidth; 73 | else self.ratingView.starPlaceHolderBorderWidth = self.increasingWidth; 74 | } 75 | 76 | -(IBAction)setProgress:(UISlider *)sender 77 | { 78 | self.ratingView.progress = sender.value; 79 | } 80 | 81 | -(IBAction)setType:(UISegmentedControl *)sender 82 | { 83 | self.ratingView.type = sender.selectedSegmentIndex; 84 | } 85 | 86 | @end 87 | -------------------------------------------------------------------------------- /LCStarRatingViewExample/LCStarRatingViewExample/LCStarRatingViewExample/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // LCStarRatingViewExample 4 | // 5 | // Created by Guolicheng on 2016/12/20. 6 | // Copyright © 2016年 titman. 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 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 郭历成 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | LCStarRatingView 2 | 3 | ![badge-pod] ![badge-languages] ![badge-platforms] ![badge-mit] 4 | 5 | Features 6 | > * No images. 7 | > * It supports multiple UI Setting. 8 | > * It supports gestures and call back block. 9 | > * It supports counting type switch. 10 | > * It supports XIB. 11 | 12 | Counting type 13 | ```objc 14 | /** 15 | * LCStarRatingViewCountingTypeInteger [0, 1, 2, 3, 4, 5] 16 | * LCStarRatingViewCountingTypeFloat [0, 0.1, ... 0.4, ... 1, 1.1, ... 4.9, 5] 17 | * LCStarRatingViewCountingTypeHalfCutting [0, 0.5, 1, 1.5, 2, ...] 18 | */ 19 | ``` 20 | 21 | Preview (GIF) 22 | 23 | ![image](https://github.com/titman/Pictures-of-the-warehouse/blob/master/LCStarRatingView1.gif?raw=false) 24 | 25 | 26 | Call back 27 | 28 | ```objc 29 | ratingView.progressDidChangedByUser = ^(CGFloat progress){ 30 | 31 | // to do something. 32 | }; 33 | ``` 34 | 35 | Update 36 | - 1.01 37 | * Fix bugs and supports XIB. 38 | - 1.0 39 | * First commit. 40 | 41 | 42 | [badge-platforms]: https://img.shields.io/badge/platforms-iOS-lightgrey.svg 43 | [badge-pod]: https://img.shields.io/cocoapods/v/LCPhotoBrowser.svg?label=version 44 | [badge-languages]: https://img.shields.io/badge/languages-ObjC-orange.svg 45 | [badge-mit]: https://img.shields.io/badge/license-MIT-blue.svg 46 | --------------------------------------------------------------------------------