Closed vdeleon closed 10 years ago
I am a little confused. You want the label that shows the current value to be inside the handle that is moving around the circle?
Yes, i am asking for that the label that shows the current value to be inside the handle moving around the circle. I having trouble trying to implement that.
@vdeleon, a quick and dirty way is to expose a handleCenter property on the slider:
// EFCircularSlider.h
@property (nonatomic) CGPoint handleCenter;
Update at the bottom of drawHandle:
:
// EFCircularSlider.m
-(void) drawHandle:(CGContextRef)ctx{
...
self.handleCenter = handleCenter;
}
Then create a label and set its center equal to the handleCenter
in hourDidChange:
(using the time picker example for this):
// EFTimePickerViewController.m
- (void)viewDidLoad
{
...
//... end of ViewDidLoad:
handleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 60, 25)];
handleLabel.textColor = [UIColor redColor];
handleLabel.backgroundColor = [UIColor colorWithWhite:0.0 alpha:0.8];
handleLabel.layer.cornerRadius = 5.0;
handleLabel.textAlignment = NSTextAlignmentCenter;
handleLabel.center = hourSlider.handleCenter;
[hourSlider addSubview:handleLabel];
}
-(void)hourDidChange:(EFCircularSlider*)slider {
int newVal = (int)slider.currentValue ? (int)slider.currentValue : 12;
NSString* oldTime = _timeLabel.text;
NSRange colonRange = [oldTime rangeOfString:@":"];
_timeLabel.text = [NSString stringWithFormat:@"%d:%@", newVal, [oldTime substringFromIndex:colonRange.location + 1]];
handleLabel.center = hourSlider.handleCenter;
handleLabel.text = _timeLabel.text;
}
And you'll get something like this:
Hope this helps!
@tomredman Great answer, thanks!
Your EFCircularSlider it just amazing and the cuztomization with my needs are so easy to use i want to make than in the circle is move arounde the big circle in the circle that moves around to show the value instead on a label, i have some issue trying to implement this featured. How you mind helping me with this issue???