UISlider - missing features - snap, tooltip and ti

2019-03-03 11:47发布

So I am new to IOS dev and Xcode but far from being a newbie in UI components in many other technologies. I am implementing a UISlider and investigated its API but could not find out how to:

  1. add snap behavior (0-9, when end user slides to 3.67 thumb will snap to 4)
  2. a checkbox that will show the value @ runtime(like as a hover tooltip) in the storyboard mode without the need to add a label
  3. add tics to the slider - 0-9, show a short vertical lines on every round #

Could it be that these basic features are missing? I assumed this will be part of the built-in UISlider.

Thanks

标签: ios uislider
2条回答
爱情/是我丢掉的垃圾
2楼-- · 2019-03-03 12:06

The UISlider documentation provided by Apple will help you to figure out what is and is not built in to UIKit's UISlider.

Specifically take a look at the section titled Customizing the Slider’s Appearance, that about sums it up for out-of-the-box customization.

Unfortunately, none of the items you listed are part of UISlider, but subclassing and building out that functionality would not be an issue.

查看更多
我只想做你的唯一
3楼-- · 2019-03-03 12:21

1 + 2) Yes, there is no built-in snap functionality, but you can implement it yourself easily. Just catch the value-changed events of the slider, and update its value to the desired value. The action method for rounding the slider values can update a label displaying the value, too.

2 + 3) You must implement that by yourself. These features are very use case specific. UIKit is rather than a set of small building blocks for general purposes.

查看更多
登录 后发表回答