自iOS 5.1以来,自定义MPVolumeView Thumb图像不是垂直居中的 [英] Custom MPVolumeView Thumb Image not vertically centered since iOS 5.1

查看:110
本文介绍了自iOS 5.1以来,自定义MPVolumeView Thumb图像不是垂直居中的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个需要MPVolumeView来控制音量的应用程序。它在iOS 5.1之前完美运行,但自5.1更新以来,拇指图像不再垂直居中。我尝试了一些改变想象尺寸,调整视图大小(和滑块)的东西,但似乎没有任何效果,拇指不再垂直居中。我得到一个中心拇指的唯一方法是,如果我使用默认的iOS。

I'm building an application that needs an MPVolumeView to control the volume. It worked perfectly before iOS 5.1 but since the 5.1 update the thumb image is no longer vertically centered. I tried a few things like changing imagine dimensions, resizing my views (and slider) but nothing seems to work, the thumb is just not vertically centered anymore. The only way i get a centered thumb is if i use the default iOS one.

我尝试将UISlider添加到具有精确的最小,最大和拇指图像的另一个视图那是一个很好的中心。

I tried adding a UISlider to another view with the exact min, max and thumb image and that one is centered fine.

这是MPVolumeView的代码:

Here is the code for the MPVolumeView:

MPVolumeView *volumeView;
volumeView = [[[MPVolumeView alloc] initWithFrame:volumeViewHolder.bounds] autorelease];
[volumeViewHolder addSubview:volumeView];

UIView  *volumeViewSlider;
for (UIView *view in [volumeView subviews])
{
    if ([[[view class] description] isEqualToString:@"MPVolumeSlider"])
    {
        volumeViewSlider = view;
    }
}

[(UISlider *)volumeViewSlider setThumbImage:sliderHandleIcon forState:UIControlStateNormal];
    [(UISlider *)volumeViewSlider setMinimumTrackImage:leftTrackImage forState:UIControlStateNormal];
    [(UISlider *)volumeViewSlider setMaximumTrackImage:rightTrackImage forState:UIControlStateNormal];

volumeViewHolder只是一个153x33的UIView。我在屏幕截图中将拇指放在绿色中。

volumeViewHolder is just a UIView thats 153x33. I put the thumb in green in the screenshot.

推荐答案

也许是一个更好的解决方案:

Maybe a better solution:

用户在底部有一个透明边框的更大图像。 Retina显示器应该在10px左右。

User a bigger image with a transparent border on the bottom. Should be around 10px for Retina Displays.

这篇关于自iOS 5.1以来,自定义MPVolumeView Thumb图像不是垂直居中的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆