2
如何更改我用作thumbImage的UIImage的大小。我用來設置圖像的代碼如下。更改UISlider的大小thumbImage
let image: UIImage = UIImage(assetIdentifier: UIImage.AssetIdentifier.Slider)
我使用Enum來獲取圖像,沒有問題。
我用來設置thumbImage的代碼如下。
self.setThumbImage(image, forState: UIControlState.Normal)
我曾嘗試使用下面的代碼來改變拇指大小的圖像試過,但無法找到解決方案。
let trackRect: CGRect = CGRect(x: 0.0, y: 0, width: self.frame.size.width, height: self.frame.size.height)
let thumbRect: CGRect = CGRect(x: 0.0, y: 0.0, width: 12.0, height: 12.0)
thumbRectForBounds(thumbRect, trackRect: trackRect, value: 0.0)
該圖像目前是40pt乘40pt(它的一個圓圈)。我希望圖像24點到24點左右。
此外,這是在Xcode7的Swift 2中。我知道這些方法適用於iOS8.0或更高版本,這是我的部署目標。
謝謝你的回答。我非常感謝這個幫助,但就成長和萎縮而言,我認爲這不是很好的用戶界面。只是一個意見。 –