2015-10-02 77 views
0

我已經改變了UISlider的拇指image.But我不能改變圖像的大小自定義UISilder的拇指

var image=UIImage(named: "thumb.png")        
    slider.setThumbImage(image, forState: UIControlState.Normal) 

我發現滑塊功能slider.thumbRectForBounds但它不幫我

回答

1

嘗試了這一點

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) 
+0

正是我想要的! –

+0

很高興幫助,歡呼:-)! – Abhinav

相關問題