Home CGAffineTransform scale with slider

# CGAffineTransform scale with slider

Joe
1#
Joe Published in 2017-11-15 01:00:58Z
 I have a UISlider which goes from 0 to 275. I want to use the slider to scale an UIImageView. When my slider value is 0 my UIImageView should have the original size (scaleX: 1, scaleY: 1). When my slider value is 275 my UIImageView should scale to 0.85. Can someone suggest a good formula to calculate the scale value in relationship with slider value? Something like this let scale = slider.value >= 275 ? 0.85 : 1 imageView.transform = CGAffineTransform(scaleX: scale, scaleY: scale)  But I have some trouble making the scale dynamic based on slider value.
vacawama
2#
 You could use a linear scale such as: let scale = 1.0 - slider.value/275.0 * 0.15