├── .gitignore ├── Classes ├── FavStarControlAppDelegate.h ├── FavStarControlAppDelegate.m ├── FavStarControlViewController.h ├── FavStarControlViewController.m ├── JSFavStarControl.h └── JSFavStarControl.m ├── FavStarControl-Info.plist ├── FavStarControl.xcodeproj └── project.pbxproj ├── FavStarControlViewController.xib ├── FavStarControl_Prefix.pch ├── MainWindow.xib ├── README.mdown ├── dot.png ├── index.html ├── main.m └── star.png /.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | 3 | *.pbxuser 4 | *.perspectivev3 5 | -------------------------------------------------------------------------------- /Classes/FavStarControlAppDelegate.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @class FavStarControlViewController; 4 | 5 | @interface FavStarControlAppDelegate : NSObject { 6 | UIWindow *window; 7 | FavStarControlViewController *viewController; 8 | } 9 | 10 | @property (nonatomic, retain) IBOutlet UIWindow *window; 11 | @property (nonatomic, retain) IBOutlet FavStarControlViewController *viewController; 12 | 13 | @end 14 | 15 | -------------------------------------------------------------------------------- /Classes/FavStarControlAppDelegate.m: -------------------------------------------------------------------------------- 1 | #import "FavStarControlAppDelegate.h" 2 | #import "FavStarControlViewController.h" 3 | 4 | @implementation FavStarControlAppDelegate 5 | 6 | @synthesize window; 7 | @synthesize viewController; 8 | 9 | 10 | - (void)applicationDidFinishLaunching:(UIApplication *)application { 11 | 12 | // Override point for customization after app launch 13 | [window addSubview:viewController.view]; 14 | [window makeKeyAndVisible]; 15 | } 16 | 17 | 18 | - (void)dealloc { 19 | [viewController release]; 20 | [window release]; 21 | [super dealloc]; 22 | } 23 | 24 | 25 | @end 26 | -------------------------------------------------------------------------------- /Classes/FavStarControlViewController.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface FavStarControlViewController : UIViewController { 4 | 5 | IBOutlet UILabel *label; 6 | 7 | } 8 | 9 | @end 10 | 11 | -------------------------------------------------------------------------------- /Classes/FavStarControlViewController.m: -------------------------------------------------------------------------------- 1 | #import "FavStarControlViewController.h" 2 | #import "JSFavStarControl.h" 3 | 4 | @implementation FavStarControlViewController 5 | 6 | /* 7 | // The designated initializer. Override to perform setup that is required before the view is loaded. 8 | - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { 9 | if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) { 10 | // Custom initialization 11 | } 12 | return self; 13 | } 14 | */ 15 | 16 | /* 17 | // Implement loadView to create a view hierarchy programmatically, without using a nib. 18 | - (void)loadView { 19 | } 20 | */ 21 | 22 | 23 | - (void)viewDidLoad 24 | { 25 | [super viewDidLoad]; 26 | 27 | UIImage *dot, *star; 28 | dot = [UIImage imageNamed:@"dot.png"]; 29 | star = [UIImage imageNamed:@"star.png"]; 30 | JSFavStarControl *rating = [[JSFavStarControl alloc] initWithLocation:CGPointMake(110, 220) dotImage:dot starImage:star]; 31 | [rating addTarget:self action:@selector(updateRating:) forControlEvents:UIControlEventValueChanged]; 32 | [self.view addSubview:rating]; 33 | [rating release]; 34 | } 35 | 36 | - (void)updateRating:(id)sender 37 | { 38 | NSLog(@"Rating: %d", [(JSFavStarControl *)sender rating]); 39 | [label setText:[NSString stringWithFormat:@"%d", [(JSFavStarControl *)sender rating]]]; 40 | } 41 | 42 | /* 43 | // Override to allow orientations other than the default portrait orientation. 44 | - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 45 | // Return YES for supported orientations 46 | return (interfaceOrientation == UIInterfaceOrientationPortrait); 47 | } 48 | */ 49 | 50 | - (void)didReceiveMemoryWarning { 51 | // Releases the view if it doesn't have a superview. 52 | [super didReceiveMemoryWarning]; 53 | 54 | // Release any cached data, images, etc that aren't in use. 55 | } 56 | 57 | - (void)viewDidUnload { 58 | // Release any retained subviews of the main view. 59 | // e.g. self.myOutlet = nil; 60 | } 61 | 62 | 63 | - (void)dealloc { 64 | [super dealloc]; 65 | } 66 | 67 | @end 68 | -------------------------------------------------------------------------------- /Classes/JSFavStarControl.h: -------------------------------------------------------------------------------- 1 | // 2 | // JSFaveStarControl.m 3 | // FavStarControl 4 | // 5 | // Created by James "Jasarien" Addyman on 17/02/2010. 6 | // Copyright 2010 JamSoft. All rights reserved. 7 | // http://jamsoftonline.com 8 | // 9 | 10 | #import 11 | 12 | 13 | @interface JSFavStarControl : UIControl { 14 | 15 | NSInteger _rating; 16 | 17 | UIImage *_dot, *_star; 18 | } 19 | 20 | @property (nonatomic, readonly) NSInteger rating; 21 | 22 | // dotImage and starImage can both be nil, or not even a dot or a star (a any images you want!) 23 | // If either of these parameters are nil, the class will draw its own dot/star 24 | // Use location to position the favstar control in your view - the control will manage its own width/height (kind of like UIActivityIndicator) 25 | - (id)initWithLocation:(CGPoint)location dotImage:(UIImage *)dotImage starImage:(UIImage *)starImage; 26 | 27 | @end 28 | -------------------------------------------------------------------------------- /Classes/JSFavStarControl.m: -------------------------------------------------------------------------------- 1 | // 2 | // JSFaveStarControl.m 3 | // FavStarControl 4 | // 5 | // Created by James "Jasarien" Addyman on 17/02/2010. 6 | // Copyright 2010 JamSoft. All rights reserved. 7 | // http://jamsoftonline.com 8 | // 9 | 10 | #import "JSFavStarControl.h" 11 | 12 | #define RATING_MAX 5 13 | 14 | @implementation JSFavStarControl 15 | 16 | @synthesize rating = _rating; 17 | 18 | - (id)initWithLocation:(CGPoint)location dotImage:(UIImage *)dotImage starImage:(UIImage *)starImage 19 | { 20 | if (self = [self initWithFrame:CGRectMake(location.x, location.y, 100, 20)]) 21 | { 22 | _rating = 0; 23 | self.backgroundColor = [UIColor clearColor]; 24 | self.opaque = NO; 25 | 26 | _dot = [dotImage retain]; 27 | _star = [starImage retain]; 28 | } 29 | 30 | return self; 31 | } 32 | 33 | - (void)drawRect:(CGRect)rect 34 | { 35 | CGPoint currPoint = CGPointZero; 36 | 37 | for (int i = 0; i < _rating; i++) 38 | { 39 | if (_star) 40 | [_star drawAtPoint:currPoint]; 41 | else 42 | [@"★" drawAtPoint:currPoint withFont:[UIFont boldSystemFontOfSize:22]]; 43 | 44 | currPoint.x += 20; 45 | } 46 | 47 | NSInteger remaining = RATING_MAX - _rating; 48 | 49 | for (int i = 0; i < remaining; i++) 50 | { 51 | if (_dot) 52 | [_dot drawAtPoint:currPoint]; 53 | else 54 | [@" •" drawAtPoint:currPoint withFont:[UIFont boldSystemFontOfSize:22]]; 55 | currPoint.x += 20; 56 | } 57 | } 58 | 59 | 60 | - (void)dealloc 61 | { 62 | [_dot release]; 63 | [_star release]; 64 | 65 | _dot = nil, 66 | _star = nil; 67 | 68 | [super dealloc]; 69 | } 70 | 71 | 72 | - (BOOL)beginTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event 73 | { 74 | CGFloat width = self.frame.size.width; 75 | CGRect section = CGRectMake(0, 0, width / RATING_MAX, self.frame.size.height); 76 | 77 | CGPoint touchLocation = [touch locationInView:self]; 78 | 79 | for (int i = 0; i < RATING_MAX; i++) 80 | { 81 | if (touchLocation.x > section.origin.x && touchLocation.x < section.origin.x + section.size.width) 82 | { // touch is inside section 83 | if (_rating != (i+1)) 84 | { 85 | _rating = i+1; 86 | [self sendActionsForControlEvents:UIControlEventValueChanged]; 87 | } 88 | 89 | break; 90 | } 91 | 92 | section.origin.x += section.size.width; 93 | } 94 | 95 | [self setNeedsDisplay]; 96 | return YES; 97 | } 98 | 99 | - (BOOL)continueTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event 100 | { 101 | CGFloat width = self.frame.size.width; 102 | CGRect section = CGRectMake(0, 0, width / RATING_MAX, self.frame.size.height); 103 | 104 | CGPoint touchLocation = [touch locationInView:self]; 105 | 106 | if (touchLocation.x < 0) 107 | { 108 | if (_rating != 0) 109 | { 110 | _rating = 0; 111 | [self sendActionsForControlEvents:UIControlEventValueChanged]; 112 | } 113 | } 114 | else if (touchLocation.x > width) 115 | { 116 | if (_rating != 5) 117 | { 118 | _rating = 5; 119 | [self sendActionsForControlEvents:UIControlEventValueChanged]; 120 | } 121 | } 122 | else 123 | { 124 | for (int i = 0; i < RATING_MAX; i++) 125 | { 126 | if (touchLocation.x > section.origin.x && touchLocation.x < section.origin.x + section.size.width) 127 | { // touch is inside section 128 | if (_rating != (i+1)) 129 | { 130 | _rating = i+1; 131 | [self sendActionsForControlEvents:UIControlEventValueChanged]; 132 | } 133 | break; 134 | } 135 | 136 | section.origin.x += section.size.width; 137 | } 138 | } 139 | 140 | [self setNeedsDisplay]; 141 | return YES; 142 | } 143 | 144 | - (void)endTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event 145 | { 146 | CGFloat width = self.frame.size.width; 147 | CGRect section = CGRectMake(0, 0, width / RATING_MAX, self.frame.size.height); 148 | 149 | CGPoint touchLocation = [touch locationInView:self]; 150 | 151 | if (touchLocation.x < 0) 152 | { 153 | if (_rating != 0) 154 | { 155 | _rating = 0; 156 | [self sendActionsForControlEvents:UIControlEventValueChanged]; 157 | } 158 | } 159 | else if (touchLocation.x > width) 160 | { 161 | if (_rating != 5) 162 | { 163 | _rating = 5; 164 | [self sendActionsForControlEvents:UIControlEventValueChanged]; 165 | } 166 | 167 | } 168 | else 169 | { 170 | for (int i = 0; i < RATING_MAX; i++) 171 | { 172 | if (touchLocation.x > section.origin.x && touchLocation.x < section.origin.x + section.size.width) 173 | { 174 | if (_rating != (i+1)) 175 | { 176 | _rating = i+1; 177 | [self sendActionsForControlEvents:UIControlEventValueChanged]; 178 | } 179 | 180 | break; 181 | } 182 | 183 | section.origin.x += section.size.width; 184 | } 185 | } 186 | 187 | [self setNeedsDisplay]; 188 | } 189 | 190 | @end 191 | -------------------------------------------------------------------------------- /FavStarControl-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIconFile 12 | 13 | CFBundleIdentifier 14 | com.yourcompany.${PRODUCT_NAME:rfc1034identifier} 15 | CFBundleInfoDictionaryVersion 16 | 6.0 17 | CFBundleName 18 | ${PRODUCT_NAME} 19 | CFBundlePackageType 20 | APPL 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0 25 | LSRequiresIPhoneOS 26 | 27 | NSMainNibFile 28 | MainWindow 29 | 30 | 31 | -------------------------------------------------------------------------------- /FavStarControl.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 45; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 1D3623260D0F684500981E51 /* FavStarControlAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 1D3623250D0F684500981E51 /* FavStarControlAppDelegate.m */; }; 11 | 1D60589B0D05DD56006BFB54 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; }; 12 | 1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; }; 13 | 1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */; }; 14 | 288765A50DF7441C002DB57D /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 288765A40DF7441C002DB57D /* CoreGraphics.framework */; }; 15 | 2899E5220DE3E06400AC0155 /* FavStarControlViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 2899E5210DE3E06400AC0155 /* FavStarControlViewController.xib */; }; 16 | 28AD733F0D9D9553002E5188 /* MainWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = 28AD733E0D9D9553002E5188 /* MainWindow.xib */; }; 17 | 28D7ACF80DDB3853001CB0EB /* FavStarControlViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 28D7ACF70DDB3853001CB0EB /* FavStarControlViewController.m */; }; 18 | 758D370E112C04F6003C8E62 /* JSFavStarControl.m in Sources */ = {isa = PBXBuildFile; fileRef = 758D370D112C04F6003C8E62 /* JSFavStarControl.m */; }; 19 | 758D3711112C0881003C8E62 /* dot.png in Resources */ = {isa = PBXBuildFile; fileRef = 758D370F112C0881003C8E62 /* dot.png */; }; 20 | 758D3712112C0881003C8E62 /* star.png in Resources */ = {isa = PBXBuildFile; fileRef = 758D3710112C0881003C8E62 /* star.png */; }; 21 | /* End PBXBuildFile section */ 22 | 23 | /* Begin PBXFileReference section */ 24 | 1D30AB110D05D00D00671497 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 25 | 1D3623240D0F684500981E51 /* FavStarControlAppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FavStarControlAppDelegate.h; sourceTree = ""; }; 26 | 1D3623250D0F684500981E51 /* FavStarControlAppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FavStarControlAppDelegate.m; sourceTree = ""; }; 27 | 1D6058910D05DD3D006BFB54 /* FavStarControl.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = FavStarControl.app; sourceTree = BUILT_PRODUCTS_DIR; }; 28 | 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 29 | 288765A40DF7441C002DB57D /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 30 | 2899E5210DE3E06400AC0155 /* FavStarControlViewController.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = FavStarControlViewController.xib; sourceTree = ""; }; 31 | 28AD733E0D9D9553002E5188 /* MainWindow.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = MainWindow.xib; sourceTree = ""; }; 32 | 28D7ACF60DDB3853001CB0EB /* FavStarControlViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FavStarControlViewController.h; sourceTree = ""; }; 33 | 28D7ACF70DDB3853001CB0EB /* FavStarControlViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FavStarControlViewController.m; sourceTree = ""; }; 34 | 29B97316FDCFA39411CA2CEA /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 35 | 32CA4F630368D1EE00C91783 /* FavStarControl_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FavStarControl_Prefix.pch; sourceTree = ""; }; 36 | 758D370C112C04F6003C8E62 /* JSFavStarControl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSFavStarControl.h; sourceTree = ""; }; 37 | 758D370D112C04F6003C8E62 /* JSFavStarControl.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JSFavStarControl.m; sourceTree = ""; }; 38 | 758D370F112C0881003C8E62 /* dot.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = dot.png; sourceTree = ""; }; 39 | 758D3710112C0881003C8E62 /* star.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = star.png; sourceTree = ""; }; 40 | 8D1107310486CEB800E47090 /* FavStarControl-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "FavStarControl-Info.plist"; plistStructureDefinitionIdentifier = "com.apple.xcode.plist.structure-definition.iphone.info-plist"; sourceTree = ""; }; 41 | /* End PBXFileReference section */ 42 | 43 | /* Begin PBXFrameworksBuildPhase section */ 44 | 1D60588F0D05DD3D006BFB54 /* Frameworks */ = { 45 | isa = PBXFrameworksBuildPhase; 46 | buildActionMask = 2147483647; 47 | files = ( 48 | 1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */, 49 | 1DF5F4E00D08C38300B7A737 /* UIKit.framework in Frameworks */, 50 | 288765A50DF7441C002DB57D /* CoreGraphics.framework in Frameworks */, 51 | ); 52 | runOnlyForDeploymentPostprocessing = 0; 53 | }; 54 | /* End PBXFrameworksBuildPhase section */ 55 | 56 | /* Begin PBXGroup section */ 57 | 080E96DDFE201D6D7F000001 /* Classes */ = { 58 | isa = PBXGroup; 59 | children = ( 60 | 1D3623240D0F684500981E51 /* FavStarControlAppDelegate.h */, 61 | 1D3623250D0F684500981E51 /* FavStarControlAppDelegate.m */, 62 | 28D7ACF60DDB3853001CB0EB /* FavStarControlViewController.h */, 63 | 28D7ACF70DDB3853001CB0EB /* FavStarControlViewController.m */, 64 | 758D370C112C04F6003C8E62 /* JSFavStarControl.h */, 65 | 758D370D112C04F6003C8E62 /* JSFavStarControl.m */, 66 | ); 67 | path = Classes; 68 | sourceTree = ""; 69 | }; 70 | 19C28FACFE9D520D11CA2CBB /* Products */ = { 71 | isa = PBXGroup; 72 | children = ( 73 | 1D6058910D05DD3D006BFB54 /* FavStarControl.app */, 74 | ); 75 | name = Products; 76 | sourceTree = ""; 77 | }; 78 | 29B97314FDCFA39411CA2CEA /* CustomTemplate */ = { 79 | isa = PBXGroup; 80 | children = ( 81 | 080E96DDFE201D6D7F000001 /* Classes */, 82 | 29B97315FDCFA39411CA2CEA /* Other Sources */, 83 | 29B97317FDCFA39411CA2CEA /* Resources */, 84 | 29B97323FDCFA39411CA2CEA /* Frameworks */, 85 | 19C28FACFE9D520D11CA2CBB /* Products */, 86 | ); 87 | name = CustomTemplate; 88 | sourceTree = ""; 89 | }; 90 | 29B97315FDCFA39411CA2CEA /* Other Sources */ = { 91 | isa = PBXGroup; 92 | children = ( 93 | 32CA4F630368D1EE00C91783 /* FavStarControl_Prefix.pch */, 94 | 29B97316FDCFA39411CA2CEA /* main.m */, 95 | ); 96 | name = "Other Sources"; 97 | sourceTree = ""; 98 | }; 99 | 29B97317FDCFA39411CA2CEA /* Resources */ = { 100 | isa = PBXGroup; 101 | children = ( 102 | 758D370F112C0881003C8E62 /* dot.png */, 103 | 758D3710112C0881003C8E62 /* star.png */, 104 | 2899E5210DE3E06400AC0155 /* FavStarControlViewController.xib */, 105 | 28AD733E0D9D9553002E5188 /* MainWindow.xib */, 106 | 8D1107310486CEB800E47090 /* FavStarControl-Info.plist */, 107 | ); 108 | name = Resources; 109 | sourceTree = ""; 110 | }; 111 | 29B97323FDCFA39411CA2CEA /* Frameworks */ = { 112 | isa = PBXGroup; 113 | children = ( 114 | 1DF5F4DF0D08C38300B7A737 /* UIKit.framework */, 115 | 1D30AB110D05D00D00671497 /* Foundation.framework */, 116 | 288765A40DF7441C002DB57D /* CoreGraphics.framework */, 117 | ); 118 | name = Frameworks; 119 | sourceTree = ""; 120 | }; 121 | /* End PBXGroup section */ 122 | 123 | /* Begin PBXNativeTarget section */ 124 | 1D6058900D05DD3D006BFB54 /* FavStarControl */ = { 125 | isa = PBXNativeTarget; 126 | buildConfigurationList = 1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "FavStarControl" */; 127 | buildPhases = ( 128 | 1D60588D0D05DD3D006BFB54 /* Resources */, 129 | 1D60588E0D05DD3D006BFB54 /* Sources */, 130 | 1D60588F0D05DD3D006BFB54 /* Frameworks */, 131 | ); 132 | buildRules = ( 133 | ); 134 | dependencies = ( 135 | ); 136 | name = FavStarControl; 137 | productName = FavStarControl; 138 | productReference = 1D6058910D05DD3D006BFB54 /* FavStarControl.app */; 139 | productType = "com.apple.product-type.application"; 140 | }; 141 | /* End PBXNativeTarget section */ 142 | 143 | /* Begin PBXProject section */ 144 | 29B97313FDCFA39411CA2CEA /* Project object */ = { 145 | isa = PBXProject; 146 | buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "FavStarControl" */; 147 | compatibilityVersion = "Xcode 3.1"; 148 | developmentRegion = English; 149 | hasScannedForEncodings = 1; 150 | knownRegions = ( 151 | English, 152 | Japanese, 153 | French, 154 | German, 155 | ); 156 | mainGroup = 29B97314FDCFA39411CA2CEA /* CustomTemplate */; 157 | projectDirPath = ""; 158 | projectRoot = ""; 159 | targets = ( 160 | 1D6058900D05DD3D006BFB54 /* FavStarControl */, 161 | ); 162 | }; 163 | /* End PBXProject section */ 164 | 165 | /* Begin PBXResourcesBuildPhase section */ 166 | 1D60588D0D05DD3D006BFB54 /* Resources */ = { 167 | isa = PBXResourcesBuildPhase; 168 | buildActionMask = 2147483647; 169 | files = ( 170 | 28AD733F0D9D9553002E5188 /* MainWindow.xib in Resources */, 171 | 2899E5220DE3E06400AC0155 /* FavStarControlViewController.xib in Resources */, 172 | 758D3711112C0881003C8E62 /* dot.png in Resources */, 173 | 758D3712112C0881003C8E62 /* star.png in Resources */, 174 | ); 175 | runOnlyForDeploymentPostprocessing = 0; 176 | }; 177 | /* End PBXResourcesBuildPhase section */ 178 | 179 | /* Begin PBXSourcesBuildPhase section */ 180 | 1D60588E0D05DD3D006BFB54 /* Sources */ = { 181 | isa = PBXSourcesBuildPhase; 182 | buildActionMask = 2147483647; 183 | files = ( 184 | 1D60589B0D05DD56006BFB54 /* main.m in Sources */, 185 | 1D3623260D0F684500981E51 /* FavStarControlAppDelegate.m in Sources */, 186 | 28D7ACF80DDB3853001CB0EB /* FavStarControlViewController.m in Sources */, 187 | 758D370E112C04F6003C8E62 /* JSFavStarControl.m in Sources */, 188 | ); 189 | runOnlyForDeploymentPostprocessing = 0; 190 | }; 191 | /* End PBXSourcesBuildPhase section */ 192 | 193 | /* Begin XCBuildConfiguration section */ 194 | 1D6058940D05DD3E006BFB54 /* Debug */ = { 195 | isa = XCBuildConfiguration; 196 | buildSettings = { 197 | ALWAYS_SEARCH_USER_PATHS = NO; 198 | COPY_PHASE_STRIP = NO; 199 | GCC_DYNAMIC_NO_PIC = NO; 200 | GCC_OPTIMIZATION_LEVEL = 0; 201 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 202 | GCC_PREFIX_HEADER = FavStarControl_Prefix.pch; 203 | INFOPLIST_FILE = "FavStarControl-Info.plist"; 204 | PRODUCT_NAME = FavStarControl; 205 | }; 206 | name = Debug; 207 | }; 208 | 1D6058950D05DD3E006BFB54 /* Release */ = { 209 | isa = XCBuildConfiguration; 210 | buildSettings = { 211 | ALWAYS_SEARCH_USER_PATHS = NO; 212 | COPY_PHASE_STRIP = YES; 213 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 214 | GCC_PREFIX_HEADER = FavStarControl_Prefix.pch; 215 | INFOPLIST_FILE = "FavStarControl-Info.plist"; 216 | PRODUCT_NAME = FavStarControl; 217 | }; 218 | name = Release; 219 | }; 220 | C01FCF4F08A954540054247B /* Debug */ = { 221 | isa = XCBuildConfiguration; 222 | buildSettings = { 223 | ARCHS = "$(ARCHS_STANDARD_32_BIT)"; 224 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 225 | GCC_C_LANGUAGE_STANDARD = c99; 226 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 227 | GCC_WARN_UNUSED_VARIABLE = YES; 228 | PREBINDING = NO; 229 | SDKROOT = iphoneos4.1; 230 | }; 231 | name = Debug; 232 | }; 233 | C01FCF5008A954540054247B /* Release */ = { 234 | isa = XCBuildConfiguration; 235 | buildSettings = { 236 | ARCHS = "$(ARCHS_STANDARD_32_BIT)"; 237 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 238 | GCC_C_LANGUAGE_STANDARD = c99; 239 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 240 | GCC_WARN_UNUSED_VARIABLE = YES; 241 | PREBINDING = NO; 242 | SDKROOT = iphoneos4.1; 243 | }; 244 | name = Release; 245 | }; 246 | /* End XCBuildConfiguration section */ 247 | 248 | /* Begin XCConfigurationList section */ 249 | 1D6058960D05DD3E006BFB54 /* Build configuration list for PBXNativeTarget "FavStarControl" */ = { 250 | isa = XCConfigurationList; 251 | buildConfigurations = ( 252 | 1D6058940D05DD3E006BFB54 /* Debug */, 253 | 1D6058950D05DD3E006BFB54 /* Release */, 254 | ); 255 | defaultConfigurationIsVisible = 0; 256 | defaultConfigurationName = Release; 257 | }; 258 | C01FCF4E08A954540054247B /* Build configuration list for PBXProject "FavStarControl" */ = { 259 | isa = XCConfigurationList; 260 | buildConfigurations = ( 261 | C01FCF4F08A954540054247B /* Debug */, 262 | C01FCF5008A954540054247B /* Release */, 263 | ); 264 | defaultConfigurationIsVisible = 0; 265 | defaultConfigurationName = Release; 266 | }; 267 | /* End XCConfigurationList section */ 268 | }; 269 | rootObject = 29B97313FDCFA39411CA2CEA /* Project object */; 270 | } 271 | -------------------------------------------------------------------------------- /FavStarControlViewController.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 784 5 | 9L31a 6 | 680 7 | 949.54 8 | 353.00 9 | 10 | YES 11 | 12 | 13 | 14 | YES 15 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 16 | 17 | 18 | YES 19 | 20 | YES 21 | 22 | 23 | YES 24 | 25 | 26 | 27 | YES 28 | 29 | IBFilesOwner 30 | 31 | 32 | IBFirstResponder 33 | 34 | 35 | 36 | 274 37 | 38 | YES 39 | 40 | 41 | 292 42 | {{20, 31}, {280, 21}} 43 | 44 | NO 45 | YES 46 | NO 47 | Label 48 | 49 | 1 50 | MCAwIDAAA 51 | 52 | 53 | 1 54 | 1.000000e+01 55 | 1 56 | 57 | 58 | {320, 460} 59 | 60 | 61 | 3 62 | MC43NQA 63 | 64 | 2 65 | 66 | 67 | NO 68 | 69 | 70 | 71 | 72 | 73 | YES 74 | 75 | 76 | view 77 | 78 | 79 | 80 | 7 81 | 82 | 83 | 84 | label 85 | 86 | 87 | 88 | 9 89 | 90 | 91 | 92 | 93 | YES 94 | 95 | 0 96 | 97 | YES 98 | 99 | 100 | 101 | 102 | 103 | -1 104 | 105 | 106 | RmlsZSdzIE93bmVyA 107 | 108 | 109 | -2 110 | 111 | 112 | 113 | 114 | 6 115 | 116 | 117 | YES 118 | 119 | 120 | 121 | 122 | 123 | 8 124 | 125 | 126 | 127 | 128 | 129 | 130 | YES 131 | 132 | YES 133 | -1.CustomClassName 134 | -2.CustomClassName 135 | 6.IBEditorWindowLastContentRect 136 | 6.IBPluginDependency 137 | 8.IBPluginDependency 138 | 139 | 140 | YES 141 | FavStarControlViewController 142 | UIResponder 143 | {{438, 347}, {320, 480}} 144 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 145 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 146 | 147 | 148 | 149 | YES 150 | 151 | YES 152 | 153 | 154 | YES 155 | 156 | 157 | 158 | 159 | YES 160 | 161 | YES 162 | 163 | 164 | YES 165 | 166 | 167 | 168 | 9 169 | 170 | 171 | 172 | YES 173 | 174 | FavStarControlViewController 175 | UIViewController 176 | 177 | label 178 | UILabel 179 | 180 | 181 | IBProjectSource 182 | Classes/FavStarControlViewController.h 183 | 184 | 185 | 186 | 187 | 0 188 | FavStarControl.xcodeproj 189 | 3 190 | 3.1 191 | 192 | 193 | -------------------------------------------------------------------------------- /FavStarControl_Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'FavStarControl' target in the 'FavStarControl' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #import 8 | #endif 9 | -------------------------------------------------------------------------------- /MainWindow.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 784 5 | 10A394 6 | 732 7 | 1027.1 8 | 430.00 9 | 10 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 11 | 60 12 | 13 | 14 | YES 15 | 16 | 17 | 18 | YES 19 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 20 | 21 | 22 | YES 23 | 24 | YES 25 | 26 | 27 | YES 28 | 29 | 30 | 31 | YES 32 | 33 | IBFilesOwner 34 | 35 | 36 | IBFirstResponder 37 | 38 | 39 | 40 | FavStarControlViewController 41 | 42 | 43 | 44 | 45 | 292 46 | {320, 480} 47 | 48 | 1 49 | MSAxIDEAA 50 | 51 | NO 52 | NO 53 | 54 | 55 | 56 | 57 | 58 | YES 59 | 60 | 61 | delegate 62 | 63 | 64 | 65 | 4 66 | 67 | 68 | 69 | viewController 70 | 71 | 72 | 73 | 11 74 | 75 | 76 | 77 | window 78 | 79 | 80 | 81 | 14 82 | 83 | 84 | 85 | 86 | YES 87 | 88 | 0 89 | 90 | 91 | 92 | 93 | 94 | -1 95 | 96 | 97 | File's Owner 98 | 99 | 100 | 3 101 | 102 | 103 | FavStarControl App Delegate 104 | 105 | 106 | -2 107 | 108 | 109 | 110 | 111 | 10 112 | 113 | 114 | 115 | 116 | 12 117 | 118 | 119 | 120 | 121 | 122 | 123 | YES 124 | 125 | YES 126 | -1.CustomClassName 127 | -2.CustomClassName 128 | 10.CustomClassName 129 | 10.IBEditorWindowLastContentRect 130 | 10.IBPluginDependency 131 | 12.IBEditorWindowLastContentRect 132 | 12.IBPluginDependency 133 | 3.CustomClassName 134 | 3.IBPluginDependency 135 | 136 | 137 | YES 138 | UIApplication 139 | UIResponder 140 | FavStarControlViewController 141 | {{512, 351}, {320, 480}} 142 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 143 | {{525, 346}, {320, 480}} 144 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 145 | FavStarControlAppDelegate 146 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin 147 | 148 | 149 | 150 | YES 151 | 152 | 153 | YES 154 | 155 | 156 | 157 | 158 | YES 159 | 160 | 161 | YES 162 | 163 | 164 | 165 | 14 166 | 167 | 168 | 169 | YES 170 | 171 | FavStarControlAppDelegate 172 | NSObject 173 | 174 | YES 175 | 176 | YES 177 | viewController 178 | window 179 | 180 | 181 | YES 182 | FavStarControlViewController 183 | UIWindow 184 | 185 | 186 | 187 | IBProjectSource 188 | Classes/FavStarControlAppDelegate.h 189 | 190 | 191 | 192 | FavStarControlAppDelegate 193 | NSObject 194 | 195 | IBUserSource 196 | 197 | 198 | 199 | 200 | FavStarControlViewController 201 | UIViewController 202 | 203 | IBProjectSource 204 | Classes/FavStarControlViewController.h 205 | 206 | 207 | 208 | 209 | 0 210 | 211 | com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3 212 | 213 | 214 | YES 215 | FavStarControl.xcodeproj 216 | 3 217 | 3.1 218 | 219 | 220 | -------------------------------------------------------------------------------- /README.mdown: -------------------------------------------------------------------------------- 1 | JSFavStarControl 2 | ================== 3 | 4 | JSFavStarControl is a UI control that resembles the 'star rating' control seen in the iPod app. 5 | 6 | JSFavStarControl allows you to select a rating between 0 and 5 stars. 7 | 8 | To use it: 9 | 10 | - `#include "JSFavStarControl.h"` where you want to use it 11 | - Create an instance, initing with a CGPoint (the position in your view from which it will be drawn) and a custom star and dot image if you wish (pass nil if you want to use the default). 12 | - Add the control as a subview of your view. 13 | 14 | License: 15 | 16 | Public Domain - there are no restrictions on the use of this code. It may be used without attribution in any commercial or non commercial application. 17 | 18 | -------------------------------------------------------------------------------- /dot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasarien/JSFavStarControl/86779b03d1a1d4beb9891c0afff62f86b7ca4647/dot.png -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | jasarien/JSFavStarControl @ GitHub 9 | 10 | 33 | 34 | 35 | 36 | 37 | Fork me on GitHub 38 | 39 |
40 | 41 |
42 | 43 | 44 | 45 | 46 |
47 | 48 |

JSFavStarControl 49 | by jasarien

50 | 51 |
52 | A simple rating control for the iPhone 53 |
54 | 55 |

A UIControl subclass that implements the behaviour of a "rating" control. The class provides support for custom images to be used for highlighted and non-highlighed "stars", or if you do not specify any, the class will draw its own. Currently only supports 5 stars, more in the works.

License

56 |

Public Domain

57 |

Authors

58 |

James Addyman (james.addyman@sky.com)

59 |

Contact

60 |

(james.addyman@sky.com)

61 | 62 | 63 |

Download

64 |

65 | You can download this project in either 66 | zip or 67 | tar formats. 68 |

69 |

You can also clone the project with Git 70 | by running: 71 |

$ git clone git://github.com/jasarien/JSFavStarControl
72 |

73 | 74 | 77 | 78 |
79 | 80 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // FavStarControl 4 | // 5 | // Created by james on 17/02/2010. 6 | // Copyright Truphone 2010. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | int main(int argc, char *argv[]) { 12 | 13 | NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; 14 | int retVal = UIApplicationMain(argc, argv, nil, nil); 15 | [pool release]; 16 | return retVal; 17 | } 18 | -------------------------------------------------------------------------------- /star.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jasarien/JSFavStarControl/86779b03d1a1d4beb9891c0afff62f86b7ca4647/star.png --------------------------------------------------------------------------------