ios - 如何自定义UISlider高度

标签 ios objective-c iphone swift uislider

我有一个项目,其中必须自定义 UISlider 元素。 我想知道是否有人知道如何更改,或者是否可以更改 UISlide 栏线的高度。

我试过这样的东西但没有用:

let customBounds = CGRect(origin: bounds.origin, 
                          size: CGSize(width: bounds.size.width, height: 15.0))
feedbackSlider.trackRectForBounds(customBounds)

谢谢

最佳答案

我希望你想在 Storyboard中编辑它,并且只有行大小,在你的自定义 UISlider 中使用它

class CustomSlide: UISlider {

     @IBInspectable var trackHeight: CGFloat = 2

     override func trackRectForBounds(bounds: CGRect) -> CGRect {
         //set your bounds here
         return CGRect(origin: bounds.origin, size: CGSizeMake(bounds.width, trackHeight))



       }
}

关于ios - 如何自定义UISlider高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31590188/

相关文章:

ios - 苹果提供的git和官方的git有区别吗?

ios - 在 iPhone 5s 或 64 位模拟器上测试 32 位 iOS 应用程序

iOS Google Maps SDK,无法收听 GMSMarker 点击事件

objective-c - 捕获子窗口 OK 单击父窗口 - Cocoa/Objective C

objective-c - stringWithContentsOfFile :usedEncoding:error: does not work

iphone - 创建 plist iPhone SDK

ios - 将 Storyboard从 iPhone 转换为 iPad

ios - TabBar 项目本地化

ios - UINavigationController 隐藏单个 View Controller 的导航栏

iphone - 困难/特殊环境中的多语言 iApp