Vignesh Vignesh - 1 month ago 8
iOS Question

iOS - How to set up an Custom class to the control programmatically

Am having and UISlider that i have created programmatically i would like to customise the UISlider appearance so i user used some UISlider custom class.

Is it possible to set up an custom class to the UISlider control programmatically without storyboard

enter image description here

Answer

First:

#import "JMMarkSlider.h";

Then declare a property like a normal property declaration:

@property (weak, nonatomic) IBOutlet JMMarkSlider *firstSlider;

Then Declare the frame and add to View as for a normal UI element:

 self.firstSlider=[[JMMarkSlider alloc]initWithFrame:CGRectMake(x,y,width,height)];

Add any DataSource and Delegate to the ViewController.h file.

Hope this helps.