0
我已經改變了UISlider的拇指image.But我不能改變圖像的大小自定義UISilder的拇指
var image=UIImage(named: "thumb.png")
slider.setThumbImage(image, forState: UIControlState.Normal)
我發現滑塊功能slider.thumbRectForBounds
但它不幫我
我已經改變了UISlider的拇指image.But我不能改變圖像的大小自定義UISilder的拇指
var image=UIImage(named: "thumb.png")
slider.setThumbImage(image, forState: UIControlState.Normal)
我發現滑塊功能slider.thumbRectForBounds
但它不幫我
嘗試了這一點
func imageWith(image : UIImage, scaledToSize:CGSize) -> UIImage {
UIGraphicsBeginImageContextWithOptions(scaledToSize, false, 0.0);
image.drawInRect(CGRectMake(0, 0, scaledToSize.width, scaledToSize.height))
let newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return newImage;
}
var image = UIImage(named: "thumb.png")
slider.setThumbImage(imageWith(image, scaledToSize: <YOUR_SIZE>), forState: UIControlState.Normal)
正是我想要的! –
很高興幫助,歡呼:-)! – Abhinav