Created
November 7, 2011 18:05
-
-
Save epatel/1345686 to your computer and use it in GitHub Desktop.
Handy lines to set tint color of a UISlider (pre iOS5)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* setting tint on slider */ | |
UIGraphicsBeginImageContextWithOptions(CGSizeMake(20, 7), NO, 1.0); | |
[[UIBezierPath bezierPathWithRoundedRect:CGRectMake(1, 0, 18, 7) | |
cornerRadius:3.0] addClip]; | |
[[UIColor grayColor] setFill]; | |
[[UIBezierPath bezierPathWithRect:CGRectMake(9, 0, 20, 7)] fill]; | |
[tintColor setFill]; | |
[[UIBezierPath bezierPathWithRect:CGRectMake(0, 0, 5+5, 7)] fill]; | |
UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(1, 1, 18, 7) | |
cornerRadius:3.0]; | |
path.lineWidth = 3; | |
[[UIColor blackColor] set]; | |
[path strokeWithBlendMode:kCGBlendModeNormal alpha:0.3]; | |
UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); | |
UIGraphicsEndImageContext(); | |
image = [image stretchableImageWithLeftCapWidth:8 topCapHeight:4]; | |
[slider setMinimumTrackImage:image forState:UIControlStateNormal]; | |
[slider setMaximumTrackImage:image forState:UIControlStateNormal]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment