How to get the center of the thumb image of UISlider

后端 未结 12 1854
挽巷
挽巷 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:43

    Swift 3.0
    Please refer if you like.

    import UIKit
    
    extension UISlider {
    
        var trackBounds: CGRect {
            return trackRect(forBounds: bounds)
        }
    
        var trackFrame: CGRect {
            guard let superView = superview else { return CGRect.zero }
            return self.convert(trackBounds, to: superView)
        }
    
        var thumbBounds: CGRect {
            return thumbRect(forBounds: frame, trackRect: trackBounds, value: value)
        }
    
        var thumbFrame: CGRect {
            return thumbRect(forBounds: bounds, trackRect: trackFrame, value: value)
        }
    }
    

提交回复
热议问题