├── .gitignore ├── LICENSE ├── README.md ├── READMEIMAGE └── TQStarRatingView.gif ├── TQStarRatingView.podspec └── TQStarRatingView ├── TQStarRating ├── Image │ ├── backgroundStar.png │ ├── backgroundStar@2x.png │ ├── foregroundStar.png │ └── foregroundStar@2x.png ├── TQStarRatingView.h └── TQStarRatingView.m ├── TQStarRatingView.xcodeproj └── project.pbxproj └── TQStarRatingView ├── Default-568h@2x.png ├── Default.png ├── Default@2x.png ├── TQAppDelegate.h ├── TQAppDelegate.m ├── TQStarRatingView-Info.plist ├── TQStarRatingView-Prefix.pch ├── TQViewController.h ├── TQViewController.m ├── en.lproj ├── InfoPlist.strings └── TQViewController.xib └── main.m /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | .DS_Store 3 | build/ 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | *.xcworkspace 13 | !default.xcworkspace 14 | xcuserdata 15 | profile 16 | *.moved-aside 17 | DerivedData 18 | .idea/ 19 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2013 TinyQ (http://tinyq.me/) 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | 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, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | TQStarRatingView 2 | ================ 3 | 4 | ## 星星评分控件 5 | 6 | iOS 星星评分视图控件,点击和滑动评分。 7 | 8 | #### 控件效果 9 | 10 | ![Image text](READMEIMAGE/TQStarRatingView.gif) 11 | 12 | #### 初始化 13 | 14 | ```objective-c 15 | TQStarRatingView *starRatingView = [[TQStarRatingView alloc] initWithFrame:CGRectMake(30, 200, 250, 50) 16 | numberOfStar:5]; 17 | starRatingView.delegate = self; 18 | [self.view addSubview:starRatingView]; 19 | ``` 20 | 21 | #### 委托回调处理分数变更 22 | 23 | ```objective-c 24 | 25 | -(void)starRatingView:(TQStarRatingView *)view score:(float)score{ 26 | self.scoreLabel.text = [NSString stringWithFormat:@"%0.2f",score * 10 ]; 27 | } 28 | 29 | ``` 30 | 31 | #### 用代码设置分数 参数需要在0-1之间。 32 | 33 | ```objective-c 34 | 35 | [self.starRatingView setScore:0.5f withAnimation:YES]; 36 | 37 | ``` 38 | 39 | ```objective-c 40 | 41 | [self.starRatingView setScore:0.5f withAnimation:YES completion:^(BOOL finished){ 42 | NSLog(@"%@",@"starOver"); 43 | }]; 44 | 45 | ``` 46 | 47 | #### About TinyQ 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /READMEIMAGE/TQStarRatingView.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TinyQ/TQStarRatingView/90bb8aafbfcbb47ff6455054f963a05eb982b435/READMEIMAGE/TQStarRatingView.gif -------------------------------------------------------------------------------- /TQStarRatingView.podspec: -------------------------------------------------------------------------------- 1 | 2 | Pod::Spec.new do |s| 3 | 4 | s.name = "TQStarRatingView" 5 | s.version = "1.1" 6 | s.summary = "iOS 星星评分视图控件,点击和滑动评分。" 7 | 8 | s.description = 'Star Rating Control, click on the slide to score a rating.' 9 | 10 | s.homepage = "https://github.com/TinyQ/TQStarRatingView" 11 | 12 | s.license = { :type => 'MIT', :text => <<-LICENSE 13 | The MIT License (MIT) 14 | 15 | Copyright (c) 2013 TinyQ (http://tinyq.me/) 16 | 17 | Permission is hereby granted, free of charge, to any person obtaining a copy of 18 | this software and associated documentation files (the "Software"), to deal in 19 | the Software without restriction, including without limitation the rights to 20 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 21 | the Software, and to permit persons to whom the Software is furnished to do so, 22 | subject to the following conditions: 23 | 24 | The above copyright notice and this permission notice shall be included in all 25 | copies or substantial portions of the Software. 26 | 27 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 28 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 29 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 30 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 31 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 32 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 33 | LICENSE 34 | } 35 | 36 | s.author = { "tinyq" => "tinyqf@gmail.com" } 37 | s.platform = :ios 38 | 39 | s.source = { :git => "https://github.com/TinyQ/TQStarRatingView.git", :tag => "1.1" } 40 | 41 | s.source_files = "TQStarRatingView/TQStarRating/**/*.{h,m}" 42 | 43 | s.resources = "TQStarRatingView/TQStarRating/**/*.png" 44 | 45 | s.requires_arc = true 46 | 47 | end 48 | -------------------------------------------------------------------------------- /TQStarRatingView/TQStarRating/Image/backgroundStar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TinyQ/TQStarRatingView/90bb8aafbfcbb47ff6455054f963a05eb982b435/TQStarRatingView/TQStarRating/Image/backgroundStar.png -------------------------------------------------------------------------------- /TQStarRatingView/TQStarRating/Image/backgroundStar@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TinyQ/TQStarRatingView/90bb8aafbfcbb47ff6455054f963a05eb982b435/TQStarRatingView/TQStarRating/Image/backgroundStar@2x.png -------------------------------------------------------------------------------- /TQStarRatingView/TQStarRating/Image/foregroundStar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TinyQ/TQStarRatingView/90bb8aafbfcbb47ff6455054f963a05eb982b435/TQStarRatingView/TQStarRating/Image/foregroundStar.png -------------------------------------------------------------------------------- /TQStarRatingView/TQStarRating/Image/foregroundStar@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TinyQ/TQStarRatingView/90bb8aafbfcbb47ff6455054f963a05eb982b435/TQStarRatingView/TQStarRating/Image/foregroundStar@2x.png -------------------------------------------------------------------------------- /TQStarRatingView/TQStarRating/TQStarRatingView.h: -------------------------------------------------------------------------------- 1 | // 2 | // TQStarRatingView.h 3 | // TQStarRatingView 4 | // 5 | // Created by fuqiang on 13-8-28. 6 | // Copyright (c) 2013年 TinyQ. All rights reserved. 7 | // 8 | 9 | 10 | #import 11 | 12 | #define kBACKGROUND_STAR @"backgroundStar" 13 | #define kFOREGROUND_STAR @"foregroundStar" 14 | #define kNUMBER_OF_STAR 5 15 | 16 | @class TQStarRatingView; 17 | 18 | @protocol StarRatingViewDelegate 19 | 20 | @optional 21 | -(void)starRatingView:(TQStarRatingView *)view score:(float)score; 22 | 23 | @end 24 | 25 | @interface TQStarRatingView : UIView 26 | 27 | @property (nonatomic, readonly) int numberOfStar; 28 | @property (nonatomic, weak) id delegate; 29 | 30 | /** 31 | * Init TQStarRatingView 32 | * 33 | * @param frame Rectangles 34 | * @param number 星星个数 35 | * 36 | * @return TQStarRatingViewObject 37 | */ 38 | - (id)initWithFrame:(CGRect)frame numberOfStar:(int)number; 39 | 40 | /** 41 | * 设置控件分数 42 | * 43 | * @param score 分数,必须在 0 - 1 之间 44 | * @param isAnimate 是否启用动画 45 | */ 46 | - (void)setScore:(float)score withAnimation:(bool)isAnimate; 47 | 48 | /** 49 | * 设置控件分数 50 | * 51 | * @param score 分数,必须在 0 - 1 之间 52 | * @param isAnimate 是否启用动画 53 | * @param completion 动画完成block 54 | */ 55 | - (void)setScore:(float)score withAnimation:(bool)isAnimate completion:(void (^)(BOOL finished))completion; 56 | 57 | @end 58 | 59 | -------------------------------------------------------------------------------- /TQStarRatingView/TQStarRating/TQStarRatingView.m: -------------------------------------------------------------------------------- 1 | // 2 | // TQStarRatingView.m 3 | // TQStarRatingView 4 | // 5 | // Created by fuqiang on 13-8-28. 6 | // Copyright (c) 2013年 TinyQ. All rights reserved. 7 | // 8 | 9 | #import "TQStarRatingView.h" 10 | 11 | @interface TQStarRatingView () 12 | 13 | @property (nonatomic, readwrite) int numberOfStar; 14 | @property (nonatomic, strong) UIView *starBackgroundView; 15 | @property (nonatomic, strong) UIView *starForegroundView; 16 | 17 | @end 18 | 19 | @implementation TQStarRatingView 20 | 21 | - (id)initWithFrame:(CGRect)frame { 22 | return [self initWithFrame:frame numberOfStar:kNUMBER_OF_STAR]; 23 | } 24 | 25 | - (void)awakeFromNib { 26 | [super awakeFromNib]; 27 | self.numberOfStar = kNUMBER_OF_STAR; 28 | [self commonInit]; 29 | } 30 | 31 | /** 32 | * 初始化TQStarRatingView 33 | * 34 | * @param frame Rectangles 35 | * @param number 星星个数 36 | * 37 | * @return TQStarRatingViewObject 38 | */ 39 | - (id)initWithFrame:(CGRect)frame numberOfStar:(int)number { 40 | self = [super initWithFrame:frame]; 41 | if (self) { 42 | _numberOfStar = number; 43 | [self commonInit]; 44 | } 45 | return self; 46 | } 47 | 48 | - (void)commonInit { 49 | self.starBackgroundView = [self buidlStarViewWithImageName:kBACKGROUND_STAR]; 50 | self.starForegroundView = [self buidlStarViewWithImageName:kFOREGROUND_STAR]; 51 | [self addSubview:self.starBackgroundView]; 52 | [self addSubview:self.starForegroundView]; 53 | } 54 | 55 | #pragma mark - Set Score 56 | 57 | /** 58 | * 设置控件分数 59 | * 60 | * @param score 分数,必须在 0 - 1 之间 61 | * @param isAnimate 是否启用动画 62 | */ 63 | - (void)setScore:(float)score withAnimation:(bool)isAnimate { 64 | [self setScore:score withAnimation:isAnimate completion:^(BOOL finished){}]; 65 | } 66 | 67 | /** 68 | * 设置控件分数 69 | * 70 | * @param score 分数,必须在 0 - 1 之间 71 | * @param isAnimate 是否启用动画 72 | * @param completion 动画完成block 73 | */ 74 | - (void)setScore:(float)score withAnimation:(bool)isAnimate completion:(void (^)(BOOL finished))completion { 75 | NSAssert((score >= 0.0)&&(score <= 1.0), @"score must be between 0 and 1"); 76 | 77 | if (score < 0) { 78 | score = 0; 79 | } 80 | if (score > 1) { 81 | score = 1; 82 | } 83 | CGPoint point = CGPointMake(score * self.frame.size.width, 0); 84 | 85 | if(isAnimate){ 86 | [UIView animateWithDuration:0.2 animations:^{ 87 | [self changeStarForegroundViewWithPoint:point]; 88 | } completion:^(BOOL finished) { 89 | if (completion){ 90 | completion(finished); 91 | } 92 | }]; 93 | } else { 94 | [self changeStarForegroundViewWithPoint:point]; 95 | } 96 | } 97 | 98 | #pragma mark - Touche Event 99 | 100 | - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { 101 | UITouch *touch = [touches anyObject]; 102 | CGPoint point = [touch locationInView:self]; 103 | CGRect rect = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height); 104 | if(CGRectContainsPoint(rect,point)) { 105 | [self changeStarForegroundViewWithPoint:point]; 106 | } 107 | } 108 | 109 | - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { 110 | UITouch *touch = [touches anyObject]; 111 | CGPoint point = [touch locationInView:self]; 112 | [UIView animateWithDuration:0.2 animations:^{ 113 | [self changeStarForegroundViewWithPoint:point]; 114 | }]; 115 | } 116 | 117 | #pragma mark - Buidl Star View 118 | 119 | /** 120 | * 通过图片构建星星视图 121 | * 122 | * @param imageName 图片名称 123 | * 124 | * @return 星星视图 125 | */ 126 | - (UIView *)buidlStarViewWithImageName:(NSString *)imageName{ 127 | CGRect frame = self.bounds; 128 | UIView *view = [[UIView alloc] initWithFrame:frame]; 129 | view.clipsToBounds = YES; 130 | for (int i = 0; i < self.numberOfStar; i ++) { 131 | UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:imageName]]; 132 | imageView.frame = CGRectMake(i * frame.size.width / self.numberOfStar, 0, frame.size.width / self.numberOfStar, frame.size.height); 133 | [view addSubview:imageView]; 134 | } 135 | return view; 136 | } 137 | 138 | #pragma mark - Change Star Foreground With Point 139 | 140 | /** 141 | * 通过坐标改变前景视图 142 | * 143 | * @param point 坐标 144 | */ 145 | - (void)changeStarForegroundViewWithPoint:(CGPoint)point{ 146 | CGPoint p = point; 147 | 148 | if (p.x < 0) { 149 | p.x = 0; 150 | } 151 | if (p.x > self.frame.size.width) { 152 | p.x = self.frame.size.width; 153 | } 154 | 155 | NSString * str = [NSString stringWithFormat:@"%0.2f",p.x / self.frame.size.width]; 156 | float score = [str floatValue]; 157 | p.x = score * self.frame.size.width; 158 | self.starForegroundView.frame = CGRectMake(0, 0, p.x, self.frame.size.height); 159 | 160 | if(self.delegate && [self.delegate respondsToSelector:@selector(starRatingView: score:)]) { 161 | [self.delegate starRatingView:self score:score]; 162 | } 163 | } 164 | 165 | @end 166 | -------------------------------------------------------------------------------- /TQStarRatingView/TQStarRatingView.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 58F0AEDC17CDD614009FE3CB /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 58F0AEDB17CDD614009FE3CB /* UIKit.framework */; }; 11 | 58F0AEDE17CDD614009FE3CB /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 58F0AEDD17CDD614009FE3CB /* Foundation.framework */; }; 12 | 58F0AEE017CDD614009FE3CB /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 58F0AEDF17CDD614009FE3CB /* CoreGraphics.framework */; }; 13 | 58F0AEE617CDD614009FE3CB /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 58F0AEE417CDD614009FE3CB /* InfoPlist.strings */; }; 14 | 58F0AEE817CDD614009FE3CB /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 58F0AEE717CDD614009FE3CB /* main.m */; }; 15 | 58F0AEEC17CDD614009FE3CB /* TQAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 58F0AEEB17CDD614009FE3CB /* TQAppDelegate.m */; }; 16 | 58F0AEEE17CDD614009FE3CB /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = 58F0AEED17CDD614009FE3CB /* Default.png */; }; 17 | 58F0AEF017CDD614009FE3CB /* Default@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 58F0AEEF17CDD614009FE3CB /* Default@2x.png */; }; 18 | 58F0AEF217CDD614009FE3CB /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 58F0AEF117CDD614009FE3CB /* Default-568h@2x.png */; }; 19 | 58F0AEF517CDD614009FE3CB /* TQViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 58F0AEF417CDD614009FE3CB /* TQViewController.m */; }; 20 | 58F0AEF817CDD614009FE3CB /* TQViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 58F0AEF617CDD614009FE3CB /* TQViewController.xib */; }; 21 | 58F0AF0117CDD6A3009FE3CB /* TQStarRatingView.m in Sources */ = {isa = PBXBuildFile; fileRef = 58F0AF0017CDD6A3009FE3CB /* TQStarRatingView.m */; }; 22 | 58F0AF0717CDDA9D009FE3CB /* backgroundStar.png in Resources */ = {isa = PBXBuildFile; fileRef = 58F0AF0317CDDA9D009FE3CB /* backgroundStar.png */; }; 23 | 58F0AF0817CDDA9D009FE3CB /* backgroundStar@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 58F0AF0417CDDA9D009FE3CB /* backgroundStar@2x.png */; }; 24 | 58F0AF0917CDDA9D009FE3CB /* foregroundStar.png in Resources */ = {isa = PBXBuildFile; fileRef = 58F0AF0517CDDA9D009FE3CB /* foregroundStar.png */; }; 25 | 58F0AF0A17CDDA9D009FE3CB /* foregroundStar@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 58F0AF0617CDDA9D009FE3CB /* foregroundStar@2x.png */; }; 26 | /* End PBXBuildFile section */ 27 | 28 | /* Begin PBXFileReference section */ 29 | 58F0AED817CDD614009FE3CB /* TQStarRatingView.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = TQStarRatingView.app; sourceTree = BUILT_PRODUCTS_DIR; }; 30 | 58F0AEDB17CDD614009FE3CB /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 31 | 58F0AEDD17CDD614009FE3CB /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 32 | 58F0AEDF17CDD614009FE3CB /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 33 | 58F0AEE317CDD614009FE3CB /* TQStarRatingView-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "TQStarRatingView-Info.plist"; sourceTree = ""; }; 34 | 58F0AEE517CDD614009FE3CB /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 35 | 58F0AEE717CDD614009FE3CB /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 36 | 58F0AEE917CDD614009FE3CB /* TQStarRatingView-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "TQStarRatingView-Prefix.pch"; sourceTree = ""; }; 37 | 58F0AEEA17CDD614009FE3CB /* TQAppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TQAppDelegate.h; sourceTree = ""; }; 38 | 58F0AEEB17CDD614009FE3CB /* TQAppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TQAppDelegate.m; sourceTree = ""; }; 39 | 58F0AEED17CDD614009FE3CB /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Default.png; sourceTree = ""; }; 40 | 58F0AEEF17CDD614009FE3CB /* Default@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default@2x.png"; sourceTree = ""; }; 41 | 58F0AEF117CDD614009FE3CB /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default-568h@2x.png"; sourceTree = ""; }; 42 | 58F0AEF317CDD614009FE3CB /* TQViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TQViewController.h; sourceTree = ""; }; 43 | 58F0AEF417CDD614009FE3CB /* TQViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = TQViewController.m; sourceTree = ""; }; 44 | 58F0AEF717CDD614009FE3CB /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/TQViewController.xib; sourceTree = ""; }; 45 | 58F0AEFF17CDD6A3009FE3CB /* TQStarRatingView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TQStarRatingView.h; sourceTree = ""; }; 46 | 58F0AF0017CDD6A3009FE3CB /* TQStarRatingView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TQStarRatingView.m; sourceTree = ""; }; 47 | 58F0AF0317CDDA9D009FE3CB /* backgroundStar.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = backgroundStar.png; sourceTree = ""; }; 48 | 58F0AF0417CDDA9D009FE3CB /* backgroundStar@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "backgroundStar@2x.png"; sourceTree = ""; }; 49 | 58F0AF0517CDDA9D009FE3CB /* foregroundStar.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = foregroundStar.png; sourceTree = ""; }; 50 | 58F0AF0617CDDA9D009FE3CB /* foregroundStar@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "foregroundStar@2x.png"; sourceTree = ""; }; 51 | /* End PBXFileReference section */ 52 | 53 | /* Begin PBXFrameworksBuildPhase section */ 54 | 58F0AED517CDD614009FE3CB /* Frameworks */ = { 55 | isa = PBXFrameworksBuildPhase; 56 | buildActionMask = 2147483647; 57 | files = ( 58 | 58F0AEDC17CDD614009FE3CB /* UIKit.framework in Frameworks */, 59 | 58F0AEDE17CDD614009FE3CB /* Foundation.framework in Frameworks */, 60 | 58F0AEE017CDD614009FE3CB /* CoreGraphics.framework in Frameworks */, 61 | ); 62 | runOnlyForDeploymentPostprocessing = 0; 63 | }; 64 | /* End PBXFrameworksBuildPhase section */ 65 | 66 | /* Begin PBXGroup section */ 67 | 58F0AECF17CDD614009FE3CB = { 68 | isa = PBXGroup; 69 | children = ( 70 | 58F0AEFE17CDD648009FE3CB /* TQStarRating */, 71 | 58F0AEE117CDD614009FE3CB /* TQStarRatingView */, 72 | 58F0AEDA17CDD614009FE3CB /* Frameworks */, 73 | 58F0AED917CDD614009FE3CB /* Products */, 74 | ); 75 | sourceTree = ""; 76 | }; 77 | 58F0AED917CDD614009FE3CB /* Products */ = { 78 | isa = PBXGroup; 79 | children = ( 80 | 58F0AED817CDD614009FE3CB /* TQStarRatingView.app */, 81 | ); 82 | name = Products; 83 | sourceTree = ""; 84 | }; 85 | 58F0AEDA17CDD614009FE3CB /* Frameworks */ = { 86 | isa = PBXGroup; 87 | children = ( 88 | 58F0AEDB17CDD614009FE3CB /* UIKit.framework */, 89 | 58F0AEDD17CDD614009FE3CB /* Foundation.framework */, 90 | 58F0AEDF17CDD614009FE3CB /* CoreGraphics.framework */, 91 | ); 92 | name = Frameworks; 93 | sourceTree = ""; 94 | }; 95 | 58F0AEE117CDD614009FE3CB /* TQStarRatingView */ = { 96 | isa = PBXGroup; 97 | children = ( 98 | 58F0AEEA17CDD614009FE3CB /* TQAppDelegate.h */, 99 | 58F0AEEB17CDD614009FE3CB /* TQAppDelegate.m */, 100 | 58F0AEF317CDD614009FE3CB /* TQViewController.h */, 101 | 58F0AEF417CDD614009FE3CB /* TQViewController.m */, 102 | 58F0AEF617CDD614009FE3CB /* TQViewController.xib */, 103 | 58F0AEE217CDD614009FE3CB /* Supporting Files */, 104 | ); 105 | path = TQStarRatingView; 106 | sourceTree = ""; 107 | }; 108 | 58F0AEE217CDD614009FE3CB /* Supporting Files */ = { 109 | isa = PBXGroup; 110 | children = ( 111 | 58F0AEE317CDD614009FE3CB /* TQStarRatingView-Info.plist */, 112 | 58F0AEE417CDD614009FE3CB /* InfoPlist.strings */, 113 | 58F0AEE717CDD614009FE3CB /* main.m */, 114 | 58F0AEE917CDD614009FE3CB /* TQStarRatingView-Prefix.pch */, 115 | 58F0AEED17CDD614009FE3CB /* Default.png */, 116 | 58F0AEEF17CDD614009FE3CB /* Default@2x.png */, 117 | 58F0AEF117CDD614009FE3CB /* Default-568h@2x.png */, 118 | ); 119 | name = "Supporting Files"; 120 | sourceTree = ""; 121 | }; 122 | 58F0AEFE17CDD648009FE3CB /* TQStarRating */ = { 123 | isa = PBXGroup; 124 | children = ( 125 | 58F0AF0217CDDA9D009FE3CB /* Image */, 126 | 58F0AEFF17CDD6A3009FE3CB /* TQStarRatingView.h */, 127 | 58F0AF0017CDD6A3009FE3CB /* TQStarRatingView.m */, 128 | ); 129 | path = TQStarRating; 130 | sourceTree = ""; 131 | }; 132 | 58F0AF0217CDDA9D009FE3CB /* Image */ = { 133 | isa = PBXGroup; 134 | children = ( 135 | 58F0AF0317CDDA9D009FE3CB /* backgroundStar.png */, 136 | 58F0AF0417CDDA9D009FE3CB /* backgroundStar@2x.png */, 137 | 58F0AF0517CDDA9D009FE3CB /* foregroundStar.png */, 138 | 58F0AF0617CDDA9D009FE3CB /* foregroundStar@2x.png */, 139 | ); 140 | path = Image; 141 | sourceTree = ""; 142 | }; 143 | /* End PBXGroup section */ 144 | 145 | /* Begin PBXNativeTarget section */ 146 | 58F0AED717CDD614009FE3CB /* TQStarRatingView */ = { 147 | isa = PBXNativeTarget; 148 | buildConfigurationList = 58F0AEFB17CDD614009FE3CB /* Build configuration list for PBXNativeTarget "TQStarRatingView" */; 149 | buildPhases = ( 150 | 58F0AED417CDD614009FE3CB /* Sources */, 151 | 58F0AED517CDD614009FE3CB /* Frameworks */, 152 | 58F0AED617CDD614009FE3CB /* Resources */, 153 | ); 154 | buildRules = ( 155 | ); 156 | dependencies = ( 157 | ); 158 | name = TQStarRatingView; 159 | productName = TQStarRatingView; 160 | productReference = 58F0AED817CDD614009FE3CB /* TQStarRatingView.app */; 161 | productType = "com.apple.product-type.application"; 162 | }; 163 | /* End PBXNativeTarget section */ 164 | 165 | /* Begin PBXProject section */ 166 | 58F0AED017CDD614009FE3CB /* Project object */ = { 167 | isa = PBXProject; 168 | attributes = { 169 | CLASSPREFIX = TQ; 170 | LastUpgradeCheck = 0810; 171 | ORGANIZATIONNAME = TinyQ; 172 | }; 173 | buildConfigurationList = 58F0AED317CDD614009FE3CB /* Build configuration list for PBXProject "TQStarRatingView" */; 174 | compatibilityVersion = "Xcode 3.2"; 175 | developmentRegion = English; 176 | hasScannedForEncodings = 0; 177 | knownRegions = ( 178 | en, 179 | ); 180 | mainGroup = 58F0AECF17CDD614009FE3CB; 181 | productRefGroup = 58F0AED917CDD614009FE3CB /* Products */; 182 | projectDirPath = ""; 183 | projectRoot = ""; 184 | targets = ( 185 | 58F0AED717CDD614009FE3CB /* TQStarRatingView */, 186 | ); 187 | }; 188 | /* End PBXProject section */ 189 | 190 | /* Begin PBXResourcesBuildPhase section */ 191 | 58F0AED617CDD614009FE3CB /* Resources */ = { 192 | isa = PBXResourcesBuildPhase; 193 | buildActionMask = 2147483647; 194 | files = ( 195 | 58F0AEE617CDD614009FE3CB /* InfoPlist.strings in Resources */, 196 | 58F0AEEE17CDD614009FE3CB /* Default.png in Resources */, 197 | 58F0AEF017CDD614009FE3CB /* Default@2x.png in Resources */, 198 | 58F0AEF217CDD614009FE3CB /* Default-568h@2x.png in Resources */, 199 | 58F0AEF817CDD614009FE3CB /* TQViewController.xib in Resources */, 200 | 58F0AF0717CDDA9D009FE3CB /* backgroundStar.png in Resources */, 201 | 58F0AF0817CDDA9D009FE3CB /* backgroundStar@2x.png in Resources */, 202 | 58F0AF0917CDDA9D009FE3CB /* foregroundStar.png in Resources */, 203 | 58F0AF0A17CDDA9D009FE3CB /* foregroundStar@2x.png in Resources */, 204 | ); 205 | runOnlyForDeploymentPostprocessing = 0; 206 | }; 207 | /* End PBXResourcesBuildPhase section */ 208 | 209 | /* Begin PBXSourcesBuildPhase section */ 210 | 58F0AED417CDD614009FE3CB /* Sources */ = { 211 | isa = PBXSourcesBuildPhase; 212 | buildActionMask = 2147483647; 213 | files = ( 214 | 58F0AEE817CDD614009FE3CB /* main.m in Sources */, 215 | 58F0AEEC17CDD614009FE3CB /* TQAppDelegate.m in Sources */, 216 | 58F0AEF517CDD614009FE3CB /* TQViewController.m in Sources */, 217 | 58F0AF0117CDD6A3009FE3CB /* TQStarRatingView.m in Sources */, 218 | ); 219 | runOnlyForDeploymentPostprocessing = 0; 220 | }; 221 | /* End PBXSourcesBuildPhase section */ 222 | 223 | /* Begin PBXVariantGroup section */ 224 | 58F0AEE417CDD614009FE3CB /* InfoPlist.strings */ = { 225 | isa = PBXVariantGroup; 226 | children = ( 227 | 58F0AEE517CDD614009FE3CB /* en */, 228 | ); 229 | name = InfoPlist.strings; 230 | sourceTree = ""; 231 | }; 232 | 58F0AEF617CDD614009FE3CB /* TQViewController.xib */ = { 233 | isa = PBXVariantGroup; 234 | children = ( 235 | 58F0AEF717CDD614009FE3CB /* en */, 236 | ); 237 | name = TQViewController.xib; 238 | sourceTree = ""; 239 | }; 240 | /* End PBXVariantGroup section */ 241 | 242 | /* Begin XCBuildConfiguration section */ 243 | 58F0AEF917CDD614009FE3CB /* Debug */ = { 244 | isa = XCBuildConfiguration; 245 | buildSettings = { 246 | ALWAYS_SEARCH_USER_PATHS = NO; 247 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 248 | CLANG_CXX_LIBRARY = "libc++"; 249 | CLANG_ENABLE_OBJC_ARC = YES; 250 | CLANG_WARN_BOOL_CONVERSION = YES; 251 | CLANG_WARN_CONSTANT_CONVERSION = YES; 252 | CLANG_WARN_EMPTY_BODY = YES; 253 | CLANG_WARN_ENUM_CONVERSION = YES; 254 | CLANG_WARN_INFINITE_RECURSION = YES; 255 | CLANG_WARN_INT_CONVERSION = YES; 256 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 257 | CLANG_WARN_UNREACHABLE_CODE = YES; 258 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 259 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 260 | COPY_PHASE_STRIP = NO; 261 | ENABLE_STRICT_OBJC_MSGSEND = YES; 262 | ENABLE_TESTABILITY = YES; 263 | GCC_C_LANGUAGE_STANDARD = gnu99; 264 | GCC_DYNAMIC_NO_PIC = NO; 265 | GCC_NO_COMMON_BLOCKS = YES; 266 | GCC_OPTIMIZATION_LEVEL = 0; 267 | GCC_PREPROCESSOR_DEFINITIONS = ( 268 | "DEBUG=1", 269 | "$(inherited)", 270 | ); 271 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 272 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 273 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 274 | GCC_WARN_UNDECLARED_SELECTOR = YES; 275 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 276 | GCC_WARN_UNUSED_FUNCTION = YES; 277 | GCC_WARN_UNUSED_VARIABLE = YES; 278 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 279 | ONLY_ACTIVE_ARCH = YES; 280 | SDKROOT = iphoneos; 281 | }; 282 | name = Debug; 283 | }; 284 | 58F0AEFA17CDD614009FE3CB /* Release */ = { 285 | isa = XCBuildConfiguration; 286 | buildSettings = { 287 | ALWAYS_SEARCH_USER_PATHS = NO; 288 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 289 | CLANG_CXX_LIBRARY = "libc++"; 290 | CLANG_ENABLE_OBJC_ARC = YES; 291 | CLANG_WARN_BOOL_CONVERSION = YES; 292 | CLANG_WARN_CONSTANT_CONVERSION = YES; 293 | CLANG_WARN_EMPTY_BODY = YES; 294 | CLANG_WARN_ENUM_CONVERSION = YES; 295 | CLANG_WARN_INFINITE_RECURSION = YES; 296 | CLANG_WARN_INT_CONVERSION = YES; 297 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 298 | CLANG_WARN_UNREACHABLE_CODE = YES; 299 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 300 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 301 | COPY_PHASE_STRIP = YES; 302 | ENABLE_STRICT_OBJC_MSGSEND = YES; 303 | GCC_C_LANGUAGE_STANDARD = gnu99; 304 | GCC_NO_COMMON_BLOCKS = YES; 305 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 306 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 307 | GCC_WARN_UNDECLARED_SELECTOR = YES; 308 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 309 | GCC_WARN_UNUSED_FUNCTION = YES; 310 | GCC_WARN_UNUSED_VARIABLE = YES; 311 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 312 | OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; 313 | SDKROOT = iphoneos; 314 | VALIDATE_PRODUCT = YES; 315 | }; 316 | name = Release; 317 | }; 318 | 58F0AEFC17CDD614009FE3CB /* Debug */ = { 319 | isa = XCBuildConfiguration; 320 | buildSettings = { 321 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 322 | GCC_PREFIX_HEADER = "TQStarRatingView/TQStarRatingView-Prefix.pch"; 323 | INFOPLIST_FILE = "TQStarRatingView/TQStarRatingView-Info.plist"; 324 | PRODUCT_BUNDLE_IDENTIFIER = "TinyQ.${PRODUCT_NAME:rfc1034identifier}"; 325 | PRODUCT_NAME = "$(TARGET_NAME)"; 326 | WRAPPER_EXTENSION = app; 327 | }; 328 | name = Debug; 329 | }; 330 | 58F0AEFD17CDD614009FE3CB /* Release */ = { 331 | isa = XCBuildConfiguration; 332 | buildSettings = { 333 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 334 | GCC_PREFIX_HEADER = "TQStarRatingView/TQStarRatingView-Prefix.pch"; 335 | INFOPLIST_FILE = "TQStarRatingView/TQStarRatingView-Info.plist"; 336 | PRODUCT_BUNDLE_IDENTIFIER = "TinyQ.${PRODUCT_NAME:rfc1034identifier}"; 337 | PRODUCT_NAME = "$(TARGET_NAME)"; 338 | WRAPPER_EXTENSION = app; 339 | }; 340 | name = Release; 341 | }; 342 | /* End XCBuildConfiguration section */ 343 | 344 | /* Begin XCConfigurationList section */ 345 | 58F0AED317CDD614009FE3CB /* Build configuration list for PBXProject "TQStarRatingView" */ = { 346 | isa = XCConfigurationList; 347 | buildConfigurations = ( 348 | 58F0AEF917CDD614009FE3CB /* Debug */, 349 | 58F0AEFA17CDD614009FE3CB /* Release */, 350 | ); 351 | defaultConfigurationIsVisible = 0; 352 | defaultConfigurationName = Release; 353 | }; 354 | 58F0AEFB17CDD614009FE3CB /* Build configuration list for PBXNativeTarget "TQStarRatingView" */ = { 355 | isa = XCConfigurationList; 356 | buildConfigurations = ( 357 | 58F0AEFC17CDD614009FE3CB /* Debug */, 358 | 58F0AEFD17CDD614009FE3CB /* Release */, 359 | ); 360 | defaultConfigurationIsVisible = 0; 361 | defaultConfigurationName = Release; 362 | }; 363 | /* End XCConfigurationList section */ 364 | }; 365 | rootObject = 58F0AED017CDD614009FE3CB /* Project object */; 366 | } 367 | -------------------------------------------------------------------------------- /TQStarRatingView/TQStarRatingView/Default-568h@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TinyQ/TQStarRatingView/90bb8aafbfcbb47ff6455054f963a05eb982b435/TQStarRatingView/TQStarRatingView/Default-568h@2x.png -------------------------------------------------------------------------------- /TQStarRatingView/TQStarRatingView/Default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TinyQ/TQStarRatingView/90bb8aafbfcbb47ff6455054f963a05eb982b435/TQStarRatingView/TQStarRatingView/Default.png -------------------------------------------------------------------------------- /TQStarRatingView/TQStarRatingView/Default@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TinyQ/TQStarRatingView/90bb8aafbfcbb47ff6455054f963a05eb982b435/TQStarRatingView/TQStarRatingView/Default@2x.png -------------------------------------------------------------------------------- /TQStarRatingView/TQStarRatingView/TQAppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // TQAppDelegate.h 3 | // TQStarRatingView 4 | // 5 | // Created by fuqiang on 13-8-28. 6 | // Copyright (c) 2013年 TinyQ. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @class TQViewController; 12 | 13 | @interface TQAppDelegate : UIResponder 14 | 15 | @property (strong, nonatomic) UIWindow *window; 16 | 17 | @property (strong, nonatomic) TQViewController *viewController; 18 | 19 | @end 20 | -------------------------------------------------------------------------------- /TQStarRatingView/TQStarRatingView/TQAppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // TQAppDelegate.m 3 | // TQStarRatingView 4 | // 5 | // Created by fuqiang on 13-8-28. 6 | // Copyright (c) 2013年 TinyQ. All rights reserved. 7 | // 8 | 9 | #import "TQAppDelegate.h" 10 | 11 | #import "TQViewController.h" 12 | 13 | @implementation TQAppDelegate 14 | 15 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 16 | { 17 | self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 18 | // Override point for customization after application launch. 19 | self.viewController = [[TQViewController alloc] initWithNibName:@"TQViewController" bundle:nil]; 20 | self.window.rootViewController = self.viewController; 21 | [self.window makeKeyAndVisible]; 22 | return YES; 23 | } 24 | 25 | - (void)applicationWillResignActive:(UIApplication *)application 26 | { 27 | // 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. 28 | // 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. 29 | } 30 | 31 | - (void)applicationDidEnterBackground:(UIApplication *)application 32 | { 33 | // 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. 34 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 35 | } 36 | 37 | - (void)applicationWillEnterForeground:(UIApplication *)application 38 | { 39 | // 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. 40 | } 41 | 42 | - (void)applicationDidBecomeActive:(UIApplication *)application 43 | { 44 | // 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. 45 | } 46 | 47 | - (void)applicationWillTerminate:(UIApplication *)application 48 | { 49 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 50 | } 51 | 52 | @end 53 | -------------------------------------------------------------------------------- /TQStarRatingView/TQStarRatingView/TQStarRatingView-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0 25 | LSRequiresIPhoneOS 26 | 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /TQStarRatingView/TQStarRatingView/TQStarRatingView-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'TQStarRatingView' target in the 'TQStarRatingView' project 3 | // 4 | 5 | #import 6 | 7 | #ifndef __IPHONE_4_0 8 | #warning "This project uses features only available in iOS SDK 4.0 and later." 9 | #endif 10 | 11 | #ifdef __OBJC__ 12 | #import 13 | #import 14 | #endif 15 | -------------------------------------------------------------------------------- /TQStarRatingView/TQStarRatingView/TQViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // TQViewController.h 3 | // TQStarRatingView 4 | // 5 | // Created by fuqiang on 13-8-28. 6 | // Copyright (c) 2013年 TinyQ. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface TQViewController : UIViewController 12 | 13 | - (IBAction)scoreButtonTouchUpInside:(id)sender; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /TQStarRatingView/TQStarRatingView/TQViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // TQViewController.m 3 | // TQStarRatingView 4 | // 5 | // Created by fuqiang on 13-8-28. 6 | // Copyright (c) 2013年 TinyQ. All rights reserved. 7 | // 8 | 9 | #import "TQViewController.h" 10 | #import "TQStarRatingView.h" 11 | 12 | @interface TQViewController () 13 | 14 | @property (nonatomic, strong) TQStarRatingView *starRatingView; 15 | @property (nonatomic, strong) IBOutlet TQStarRatingView *nibStarRatingView; 16 | @property (nonatomic, weak) IBOutlet UILabel *scoreLabel; 17 | 18 | @end 19 | 20 | @implementation TQViewController 21 | 22 | - (void)viewDidLoad 23 | { 24 | [super viewDidLoad]; 25 | 26 | self.starRatingView = [[TQStarRatingView alloc] initWithFrame:CGRectMake(30, 200, 250, 50) 27 | numberOfStar:kNUMBER_OF_STAR]; 28 | self.starRatingView.delegate = self; 29 | [self.view addSubview:self.starRatingView]; 30 | 31 | } 32 | 33 | - (void)starRatingView:(TQStarRatingView *)view score:(float)score 34 | { 35 | self.scoreLabel.text = [NSString stringWithFormat:@"%0.2f",score * 10 ]; 36 | 37 | [self.nibStarRatingView setScore:score withAnimation:YES]; 38 | } 39 | 40 | - (IBAction)scoreButtonTouchUpInside:(id)sender 41 | { 42 | //设置分数。参数需要在0-1之间。 43 | [self.starRatingView setScore:0.5f withAnimation:YES]; 44 | 45 | [self.nibStarRatingView setScore:0.5f withAnimation:YES]; 46 | 47 | //OR 48 | // [self.starRatingView setScore:0.5f withAnimation:YES completion:^(BOOL finished){ 49 | // NSLog(@"Finished"); 50 | // }]; 51 | } 52 | 53 | @end 54 | -------------------------------------------------------------------------------- /TQStarRatingView/TQStarRatingView/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /TQStarRatingView/TQStarRatingView/en.lproj/TQViewController.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 27 | 38 | 39 | 40 | 41 | 42 | 43 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /TQStarRatingView/TQStarRatingView/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // TQStarRatingView 4 | // 5 | // Created by fuqiang on 13-8-28. 6 | // Copyright (c) 2013年 TinyQ. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import "TQAppDelegate.h" 12 | 13 | int main(int argc, char *argv[]) 14 | { 15 | @autoreleasepool { 16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([TQAppDelegate class])); 17 | } 18 | } 19 | --------------------------------------------------------------------------------