How to get the center of the thumb image of UISlider

后端 未结 12 1850
挽巷
挽巷 2020-11-29 23:18

I\'m creating a custom UISlider to test out some interface ideas. Mostly based around making the thumb image larger.

I found out how to do that, <

12条回答
  •  时光说笑
    2020-11-29 23:37

    Swift 3

    extension UISlider {
        var thumbCenterX: CGFloat {
            let trackRect = self.trackRect(forBounds: frame)
            let thumbRect = self.thumbRect(forBounds: bounds, trackRect: trackRect, value: value)
            return thumbRect.midX
        }
    }
    

提交回复
热议问题