LoginSignup
1
1

More than 5 years have passed since last update.

[Swift] UIDatePickerの色を動的に変える

Last updated at Posted at 2017-06-24

[Swift] UIDatePickerの色を変える

@IBOutlet weak var myPicker: UIDatePicker!

override func viewDidLoad() {
    super.viewDidLoad()

    myPicker.backgroundColor = UIColor.white
    myPicker.setValue(UIColor.white, forKey: "textColor")

    for subview in myPicker.subviews.first!.subviews {
        if subview.frame.height < myPicker.frame.height {
            subview.layer.borderColor = UIColor.white.cgColor
            subview.layer.borderWidth = subview.frame.height
        }
    }
}
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1