How do I make an attributed string using Swift?

This answer has been updated for Swift 4.2. Quick Reference The general form for making and setting an attributed string is like this. You can find other common options below. // create attributed string let myString = “Swift Attributed String” let myAttribute = [ NSAttributedString.Key.foregroundColor: UIColor.blue ] let myAttrString = NSAttributedString(string: myString, attributes: myAttribute) // … Read more

Identify different iOS devices in coding? [closed]

The way I determine what iOS device I am running on so we can change layout based on the iDevices size such as iPad and iPhone is like. // iPhone 5 (iPhone 4″) #define IS_PHONEPOD5() ([UIScreen mainScreen].bounds.size.height == 568.0f && [UIScreen mainScreen].scale == 2.f && UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) To get iPhone 5 you could also … Read more

tech