Skip to content

Instantly share code, notes, and snippets.

@mkchoi212
Last active June 19, 2018 02:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mkchoi212/63f2f6717859bf58dcdb52cf0d9bfb55 to your computer and use it in GitHub Desktop.
Save mkchoi212/63f2f6717859bf58dcdb52cf0d9bfb55 to your computer and use it in GitHub Desktop.
UISwitch BackgroundView Bug Demo Playground File
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