iphone - How to give UIPopOver kind of functionality with simple UIVIew -
i want make uiview should displayed above slider thumb , should show value of slider. don't want use popover it's not looking artwork have.
please share views on this. don't have care apple policies application not go through apple's code review. internal survey purpose.
thanks.
find demo here, using uilabel , animation(though class name popover..but not using popover--), can go through source code, it's simple, hope can help.
original link here: uilabel on slider
- (bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions { mslider = [[uislider alloc]initwithframe:cgrectmake(10, 100, 300, 50)]; mslider.minimumvalue = 0; mslider.maximumvalue = 1000; mslider.value = 0; [mslider addtarget:self action:@selector(updatevalue:) forcontrolevents:uicontroleventvaluechanged]; popview = [[uilabel alloc]initwithframe:cgrectmake(mslider.frame.origin.x, mslider.frame.origin.y-20, 70, 20)]; [popview settextalignment:uitextalignmentcenter]; [popview setbackgroundcolor:[uicolor clearcolor]]; [popview setalpha:0.f]; self.window = [[uiwindow alloc] initwithframe:[[uiscreen mainscreen] bounds]]; [self.window addsubview:mslider]; [self.window addsubview:popview]; // override point customization after application launch. self.window.backgroundcolor = [uicolor whitecolor]; [self.window makekeyandvisible]; return yes; } - (void)updatevalue:(id)slider { uiimageview *imageview = [mslider.subviews objectatindex:2]; cgrect therect = [self.window convertrect:imageview.frame fromview:imageview.superview]; [popview setframe:cgrectmake(therect.origin.x-22, therect.origin.y-30, popview.frame.size.width, popview.frame.size.height)]; nsinteger v = mslider.value+0.5; [popview settext:[nsstring stringwithformat:@"%d",v]]; [uiview animatewithduration:0.5 animations:^{ [popview setalpha:1.f]; } completion:^(bool finished){ // someting when animation finished }]; [timer invalidate]; timer = nil; timer = [nstimer scheduledtimerwithtimeinterval:1 target:self selector:@selector(dispopview) userinfo:nil repeats:no]; } - (void)dispopview { [uiview animatewithduration:0.5 animations:^{ [popview setalpha:0.f]; } completion:^(bool finished){ //do someting when animation finished }]; }
Comments
Post a Comment