iphone - iOS6 中的 UISlider 自定义问题

标签 iphone ios user-interface ios6 uislider

我有一个自定义的 UISlider,但在 iOS 6 中,setMinimumTrackImage 存在问题,可以看到它会调整大小,而不是像 iOS 5 和 4 那样被裁剪。

我尝试在创建图像时添加 stretchableImageWithLeftCapWidth: 20 topCapHeight: 0]; 使图像可拉伸(stretch),但结果更糟,或多或少,当拇指按钮达到 LeftCapWidth 大小时图像开关从 MinimumTrackImage 到
最大轨迹图像。我找到的解决方案是为 MinimumTrackImage 使用透明的 png,并将实际的 MinimumTrackImage 作为 bgcolor。

我想知道是否有其他人遇到过这个问题,他是否有正确的方法来解决它。提前致谢。

代码:

maxImage=[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:maxImageName ofType:@"png"]];
minImage=[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:minImageName ofType:@"png"]];

[_scaleSlider setMinimumTrackImage:minImage forState:UIControlStateNormal];
[_scaleSlider setMaximumTrackImage:maxImage forState:UIControlStateNormal];

Screenshot of the Sliders

最佳答案

使用resizableImageWithCapInsets:<#(UIEdgeInsets)#>而不是 stretchableImageWithLeftCapWidth:<#(NSInteger)#> topCapHeight:<#(NSInteger)#>
它会解决你的问题

关于iphone - iOS6 中的 UISlider 自定义问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14537896/

相关文章:

c - 我应该在项目开始时考虑 GUI 吗?

ios - Swift 以编程方式生成宽度百分比

java - 我的 GUI 窗口没有显示任何内容

ios - UINavigationController popViewControllerAnimated 在 Touch Id 之后需要很长时间

iphone - iAd 无法在我的 iPhone 应用程序中运行

iphone - 将 UIActivityIndi​​cator 添加到模态视图(ELCimagepicker)

ios - UIView 中的 UITableView

ios - 删除包含标题等于 tableView textLabel 的注释

ios - 在特定页面 iOS 上打开 PDF 文件

iphone - iOS 核心数据 - 将上下文传递给详细 View 的设计模式