• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

为什么 UIProgressview 进度条不能调整大小?

用户头像
it1352
帮助1

问题说明

来自巴伐利亚关于的问题">此处为 UIProgressViews:

我尝试实现 Dave DeLong 所说的,并且我按照他在示例中展示的方式完成了所有操作,但是当我运行该程序时,如果我尝试更改进度值,我的进度条会变成一个拉伸的图像.然而,轨道图像完美地调整大小并沿轨道重复.出于某种原因,进度不会沿着进度条执行此操作.

I tried implementing what Dave DeLong said and I did everything the exact way he showed in his example, but when I run the program, my progress bar becomes a stretched image if I try changing the value of the progress. The track image however resizes perfectly and repeats along the track. For some reason, the progress isn't doing this along the progress bar.

UIImage * load = [[UIImage imagedNamed:@"load.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 1, 0, 1)];
UIImage * track = [[UIImage imageNamed:@"track.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 1, 0, 1)]; 
[progressbar progressImage:load];
[progressbar trackImage:track];
[progressbar setProgress:0.5];

我尝试将我的图像变量从进度图像切换到轨道图像,以查看是否是无法调整大小的图像(它不应该是因为它们是完全相同的图像,只是颜色不同).除了当我这样做时,轨道图像再次完美地调整大小,进度图像是拉伸的图像.有谁知道为什么会发生这种情况?

I tried switching my image variables from the progress image to the track image to see if maybe it was the image that wasn't resizable (which it shouldn't have been because they were the exact same image, just different colors). Except when I did this, the track image again resized perfectly and the progress image was the one that stretched. Does anyone know why this may be happening?

正确答案

#1

你的可调整大小的大写插图可能不应该是 {0,1,0,1}.在您的情况下,它们看起来应该是 {0,0,0,0}UIEdgeInsetsZero.

Your resizable cap insets probably shouldn't be {0,1,0,1}. In your case, it looks like they should be {0,0,0,0}, or UIEdgeInsetsZero.

我剪掉了红色和蓝色的小方块:

I clipped out the little red and blue squares:

... 然后将它们放入 UIProgressView:

... and then threw them into a UIProgressView:

UIImage *red = [[UIImage imageNamed:@"red"] resizableImageWithCapInsets:UIEdgeInsetsZero];
UIImage *blue = [[UIImage imageNamed:@"blue"] resizableImageWithCapInsets:UIEdgeInsetsZero];

[pv setTrackImage:blue];
[pv setProgressImage:red];

当进度视图以 progress 为 0.5 放置在 UI 上时,我得到了这个:

When the progress view was placed on the UI with a progress of 0.5, I got this:

我觉得不错.

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /reply/detail/tanhcfijbg
系列文章
更多 icon
同类精品
更多 icon
继续加载