Найдите здесь демонстрацию, используя UILabel и анимацию (хотя имя класса popover..но на самом деле не используется popover--), вы можете просмотреть исходный код, он очень прост, надеюсь, он может помочь.
Оригинальная ссылка здесь:
UILabel над слайдером
- (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 for 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){
// do 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
}];
}