[iphone] How to set textColor of UILabel in Swift

The text field placeholder and the "is really" label is hard to see at night. So i change their color depending one what time of day it is.

Also make sure you connect the new IBOutlet isReallyLabel. To do so open Main.storybaord and control-drag from "Convert" view controller to the "is really" text field and select the isReallyLabel under Outlets.

WARNING: I have not tested to see if the application is open while the time of day swaps.

_x000D_
_x000D_
@IBOutlet var isReallyLabel: UILabel! _x000D_
  _x000D_
override func viewWillAppear(animated: Bool) {_x000D_
 let calendar = NSCalendar.currentCalendar()_x000D_
 let hour = calendar.component(.Hour, fromDate: NSDate())_x000D_
  _x000D_
 let lightColor = UIColor.init(red: 0.961, green: 0.957, blue: 0945, alpha: 1)_x000D_
 let darkColor = UIColor.init(red: 0.184, green: 0.184 , blue: 0.188, alpha: 1)_x000D_
_x000D_
  _x000D_
 switch hour {_x000D_
 case 8...18:_x000D_
  isReallyLabel.textColor = UIColor.blackColor()_x000D_
  view.backgroundColor = lightColor_x000D_
 default:_x000D_
  let string = NSAttributedString(string: "Value", attributes: [NSForegroundColorAttributeName: UIColor.whiteColor()])_x000D_
  textField.attributedPlaceholder = string_x000D_
  isReallyLabel.textColor = UIColor.whiteColor()_x000D_
  view.backgroundColor = darkColor_x000D_
 }_x000D_
}
_x000D_
_x000D_
_x000D_

Examples related to iphone

Detect if the device is iPhone X Xcode 8 shows error that provisioning profile doesn't include signing certificate Access files in /var/mobile/Containers/Data/Application without jailbreaking iPhone Certificate has either expired or has been revoked Missing Compliance in Status when I add built for internal testing in Test Flight.How to solve? cordova run with ios error .. Error code 65 for command: xcodebuild with args: "Could not find Developer Disk Image" Reason: no suitable image found iPad Multitasking support requires these orientations How to insert new cell into UITableView in Swift

Examples related to swift

Make a VStack fill the width of the screen in SwiftUI Xcode 10.2.1 Command PhaseScriptExecution failed with a nonzero exit code Command CompileSwift failed with a nonzero exit code in Xcode 10 Convert Json string to Json object in Swift 4 iOS Swift - Get the Current Local Time and Date Timestamp Xcode 9 Swift Language Version (SWIFT_VERSION) How do I use Safe Area Layout programmatically? How can I use String substring in Swift 4? 'substring(to:)' is deprecated: Please use String slicing subscript with a 'partial range from' operator Safe Area of Xcode 9 The use of Swift 3 @objc inference in Swift 4 mode is deprecated?

Examples related to uilabel

How to make a UILabel clickable? Figure out size of UILabel based on String in Swift How to underline a UILabel in swift? Adding space/padding to a UILabel How to set textColor of UILabel in Swift Adjust UILabel height to text Setting UILabel text to bold How do I make an attributed string using Swift? How do I change the font size of a UILabel in Swift? how do I change text in a label with swift?

Examples related to xcode6

'Framework not found' in Xcode No suitable records were found verify your bundle identifier is correct unable to dequeue a cell with identifier Cell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard Move a view up only when the keyboard covers an input field My prerelease app has been "processing" for over a week in iTunes Connect, what gives? Programmatically navigate to another view controller/scene Changing the Status Bar Color for specific ViewControllers using Swift in iOS8 Change tab bar item selected color in a storyboard How do I change UIView Size? How to get textLabel of selected row in swift?

Examples related to textcolor

How can I change default dialog button text color in android 5 How to set textColor of UILabel in Swift With Twitter Bootstrap, how can I customize the h1 text color of one page and leave the other pages to be default? UIButton title text color UILabel with text of two different colors How to change the Text color of Menu item in Android? How do you use NSAttributedString?