自定义滑块轨道图像 [英] Customizing slider track images

查看:66
本文介绍了自定义滑块轨道图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想自定义UISlider,就像iBooks一样.我知道[slider setMaximumTrackImage:]和[slider setMinimumTrackImage:]可以使用.但是有人可以弄清楚我在图像中需要多少个点吗?

Hi i would like to customize my UISlider similar to the way iBooks has done. I Know that [slider setMaximumTrackImage:] and [slider setMinimumTrackImage:] are to be used.But can someone clarify as to how many dots would i need in the image?

推荐答案

图像应该是可拉伸的.从 docs :

The images are supposed to be stretchable. From the docs:

轨道图像的方向必须与轨道图像的方向匹配滑块控件.为了便于拉伸图像以填充拇指和端点之间的空间,通常是轨迹图像在三个区域中定义.两端之间有一个可拉伸的区域上限区域.端盖定义了图像剩余的部分照原样,不被拉长.可拉伸区域为1点宽可以复制以制作图像的端盖之间的区域显得更长.

The orientation of the track image must match the orientation of the slider control. To facilitate the stretching of the image to fill the space between the thumb and end point, track images are usually defined in three regions. A stretchable region sits between two end cap regions. The end caps define the portions of the image that remain as is and are not stretched. The stretchable region is a 1-point wide area between the end caps that can be replicated to make the image appear longer.

要为水平滑块定义端盖尺寸,请为图像的leftCapWidth属性分配一个适当的值.有关此值如何定义滑块区域的更多信息,请参见UIImage类.

To define the end cap sizes for a horizontally-oriented slider, assign an appropriate value to the image’s leftCapWidth property. For more information about how this value defines the regions of the slider, see the UIImage class.

因此,您绘制的图像将具有末端部分(默认滑块中最左侧的圆形部分)-其宽度由您的左笔帽宽度定义.然后是一个可以扩展到滑块长度的1像素宽的部分,然后是一个右盖(它占据了图像的其余部分).

So, the image you draw would have your end part (the rounded part on the far left in the default slider) - the width of this is defined by your left cap width. Then a 1-pixel wide part which can be stretched to the length of the slider, then a right cap (which takes up the remaining part of the image).

从理论上讲,您可以制作一个一像素宽的图像,然后将其从音轨的末端延伸到当前的拇指位置.但是,最后没有任何形状.

In theory then you could make a one-pixel wide image and this would just be stretched out from the end of the track to the current thumb position. However, this would have no shape at the end.

这篇关于自定义滑块轨道图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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