Last active
June 19, 2018 02:53
-
-
Save mkchoi212/63f2f6717859bf58dcdb52cf0d9bfb55 to your computer and use it in GitHub Desktop.
UISwitch BackgroundView Bug Demo Playground File
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
import PlaygroundSupport | |
class MyViewController : UIViewController { | |
override func loadView() { | |
let view = UIStackView() | |
view.alignment = .center | |
view.distribution = .equalCentering | |
view.axis = .horizontal | |
view.backgroundColor = .black | |
// UISwitch WITHOUT the cornerRadius set | |
// NOTE: Color leaks out from UISwitch | |
let redSwitch = UISwitch() | |
redSwitch.backgroundColor = .red | |
// UISwitch WITH the cornerRadius set | |
let blueSwitch = UISwitch() | |
blueSwitch.backgroundColor = .blue | |
blueSwitch.layer.cornerRadius = 16 | |
view.addArrangedSubview(redSwitch) | |
view.addArrangedSubview(blueSwitch) | |
self.view = view | |
} | |
} | |
PlaygroundPage.current.liveView = MyViewController() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment