UISlider changing width depending on device
Instead of hard coding the values, you could get the container views width and set the sliders width as a percentage of it.
CGRect superViewFrame = slider.superView.frame;
CGRect sliderFrame = slider.frame;
sliderFrame.size.width = <your choice for eg, superViewFrame.size.width * 0.3f>
sliderFrame.origin.x = <your choice for eg, superViewFrame.size.width * .2f>
slider.frame = sliderFrame;
Fit a Vertical UISlider into an Existing Container View?
There is no problem with this code to add and rotate the slider. The problem is that the the code must be put into the "layoutSubviews" method of the slider's parent view; instead I had it in the "layoutSubviews" of the parent view of the parent view of the slider. When my original code executed the slider's parent view had not yet been laid out and did not yet have the correct dimensions.
During "layoutSubviews" of a view, the subviews have not yet been laid out and so their bounds are not yet valid. I needed to wait until later in the layout process to get the bounds of the parent view and transform the slider to fit.
In the end, I put the code to add the slider and transform the slider in the "viewDidAppear" of the top level view controller. This was the same code as in the original question - just in a different place.
Scaling a font on a multilined UIButton depending on a device size
You can use size classes to specify the font on your button/label in IB. Just press the little + sign to the left of the font property:
Related Topics
Is There an Object Class in Swift
Add Custom .Colornames to UIcolor Somehow
iOS 10. Coredata Insert New Object Sig Abrt
Playing Multiple Wav Out Multiple Channels Avaudioengine
Osx/Swift: Call Function at a Specific Date/Time
Swiftui - Form with Error Message on Button Press and Navigation
Keep Getting an Error: "Uiimagepickercontroller Extension Discovery Failed with Error: (Null)"
Possible Bug? I Can Create Generic Instance Ignoring Constraint
Didupdateheading Not Called in Swift
Same Object Different Address. Why
Difference Between Timestamp Stored and Current Date
Sprite Kit Game Crashes on Game Over on Tvos 9.1 and iOS 9.2
How to Use Enumerated in a List of Structs in Foreach Swiftui