Reputation: 3172
I have a view controller that displays a bunch of buttons for music control. One of them is a volume control located at the button. I wish to display a mini pop-up view that contains just a vertical slider when the volume control button is clicked. How can I achieve this?
The first solution that came up on my mind is setting a slider that is hidden initially, and will be shown after the button is clicked. But I don't want this solution. I want a more "professional" way. I also searched through the net about pop up views, most of them are something like a custom alert dialog in which the background is dimmed, and I don't want that.
So please help me if you can. Thanks in advance!
Upvotes: 0
Views: 1735
Reputation: 3984
try this code:
- (void)viewDidLoad
{
[super viewDidLoad];
popupView.hidden=YES;
}
this code place in Show Slider button Click event
[self showSliderPopup];// call method
popupView.hidden=NO;
create popup method
-(void) showSliderPopup{
UISlider *slider=[[UISlider alloc]initWithFrame:CGRectMake(10, 0, 300, 300)];
CGAffineTransform trans=CGAffineTransformMakeRotation(M_PI_2);
slider.transform=trans;
slider.minimumValue=1;
slider.maximumValue=100;
slider.continuous=NO;
[slider addTarget:self action:@selector(sliderChanhge:) forControlEvents:UIControlEventValueChanged];
popupView=[[UIView alloc]initWithFrame:CGRectMake(10, 10, 300, 350)]; // set popup frame your require position
[popupView addSubview:slider];
[self.view addSubview:popupView];
}
Slider Change method
-(IBAction)sliderChanhge:(id)sender
{
NSLog(@"%d",(int)slider.value);
}
Upvotes: 1