Comments (4)
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?
from efcircularslider.
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.
from efcircularslider.
@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!
from efcircularslider.
@tomredman Great answer, thanks!
from efcircularslider.
Related Issues (20)
- default value on slider HOT 1
- Slider captures all touch gestures that begin outside of circle but within the frame rectangle HOT 1
- Set current value programatically HOT 3
- Snap to first label from left side
- Can't change currentValue
- Unable to change color of handle HOT 2
- Clipping on sides of slider
- Prevent the slider from going past max duration HOT 5
- Set UIImage to Handle HOT 1
- Maximum Value and Value per step HOT 1
- Half circle slider. HOT 2
- Start slider from another position. HOT 2
- How to prevent currentValue from being reset to zero?
- Setting currentValue animated HOT 2
- EFCircularSlider and Swift HOT 1
- How to get the revolutions count? HOT 1
- update slider from another slider
- For Android
- Changing the angle of minimum value
- How to start Slider from Bottom ?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from efcircularslider.