Giter Site home page Giter Site logo

Comments (4)

eliotfowler avatar eliotfowler commented on August 20, 2024

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.

vdeleon avatar vdeleon commented on August 20, 2024

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.

tomredman avatar tomredman commented on August 20, 2024

@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:
ios simulator screen shot 2014-02-24 11 36 46 am

Hope this helps!

from efcircularslider.

eliotfowler avatar eliotfowler commented on August 20, 2024

@tomredman Great answer, thanks!

from efcircularslider.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.