我已经(成功地)遵循了下面的教程,关于如何构建一个绘制可视化跟踪弹出视图的UISlider子类。
http://blog.neuwert-media.com/2011/04/customized-uislider-with-visual-value-tracking/
我的最后一个问题是弹出视图被其他视图imageView元素隐藏了。我一直在寻找某种显示顺序或偏好设置,但没有幸运地坚持在图像上方显示我的弹出视图。
发布于 2014-06-18 03:55:14
用这个SO Answer试试吧
[parentView bringSubviewToFront:[[parentView subviews] objectAtIndex:0]];
// or
[parentView bringSubviewToFront:popupView];发布于 2014-06-18 04:06:57
我建议将弹出窗口作为子视图添加到应用程序的keyWindow中,这样它就高于一切。这很可能是用户的预期行为。类似于:
- (void)setPopoverVisible:(BOOL)visible {
if (visible) {
[self.popover removeFromSuperview];
UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow];
[keyWindow addSubview:self.popover];
}
[UIView animateWithDuration:0.15
delay:0
options:UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionCurveEaseInOut
animations:^{
self.popover.alpha = (visible ? 1 : 0);
}
completion:^(BOOL finished) {
if (!visible) {
[self.popover removeFromSuperview];
}
}];
}请记住,当定位弹出框时,要将矩形或点(无论您用来定位滑块)转换为keyWindow的边界。例如:
- (void)positionPopover {
// Calculate newPopoverCenter in self.bounds
UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow];
self.popover.center = [self convertPoint:newPopoverCenter toView:keyWindow];
}发布于 2014-10-11 00:51:35
可以在这里找到更现代的方法:https://github.com/alskipp/ASValueTrackingSlider。也许它会解决你所遇到的问题。
https://stackoverflow.com/questions/24272206
复制相似问题