I want to create a custom slide, however I do not know how to use it in IB.
.h
@interface MainViewController : UIViewController <AVAudioPlayerDelegate> {
UISlider *customSlider;
}
@property (nonatomic, retain, readonly) UISlider *customSlider;
@end
.m
#define kSliderHeight 7.0
#define kViewTag 1
@implementation MainViewController
- (UISlider *)customSlider
{
if (customSlider == nil)
{
CGRect frame = CGRectMake(174, 12.0, 120.0, kSliderHeight);
customSlider = [[UISlider alloc] initWithFrame:frame];
[customSlider addTarget:self action:@selector(sliderAction:) forControlEvents:UIControlEventValueChanged];
customSlider.backgroundColor = [UIColor clearColor];
UIImage *stetchLeftTrack = [[UIImage imageNamed:@"orangeslide.png"]
stretchableImageWithLeftCapWidth:10.0 topCapHeight:0.0];
UIImage *stetchRightTrack = [[UIImage imageNamed:@"yellowslide.png"]
stretchableImageWithLeftCapWidth:10.0 topCapHeight:0.0];
[customSlider setThumbImage: [UIImage imageNamed:@"slider_ball.png"] forState:UIControlStateNormal];
[customSlider setMinimumTrackImage:stetchLeftTrack forState:UIControlStateNormal];
[customSlider setMaximumTrackImage:stetchRightTrack forState:UIControlStateNormal];
customSlider.minimumValue = 0.0;
customSlider.maximumValue = 100.0;
customSlider.continuous = YES;
customSlider.value = 50.0;
[customSlider setAccessibilityLabel:NSLocalizedString(@"CustomSlider", @"")];
customSlider.tag = kViewTag;
}
return customSlider;
}
All I need to know is how I apply it in IB. How to successfully build it.
thank
source
share