Reputation: 612
I have changed UISlider's thumb image.But I cant change the size of the image
var image=UIImage(named: "thumb.png")
slider.setThumbImage(image, forState: UIControlState.Normal)
I found slider function slider.thumbRectForBounds
but it doesnt help me
Upvotes: 0
Views: 56
Reputation: 38162
Try this out
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)
Upvotes: 1