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
//Way to merge NSAttributedStrings into one string | |
let mr = "Mr." | |
let name = "John" | |
let lastName = "Doe" | |
let mrString = NSMutableAttributedString(string: mr, attributes: mrAttributes) | |
let nameString = NSAttributedString(string: name, attributes: nameAttributes) | |
let lastNameString = NSAttributedString(string: lastName, attributes: lastNameAttributes) | |
mrString.append(nameString) | |
mrString.append(lastNameString) | |
//mrString is a merged result string |
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
class ViewController: UIViewController { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
let mrAttributes: [NSAttributedString.Key: Any] = [ | |
.foregroundColor: UIColor.green, //Text color | |
.font: UIFont.systemFont(ofSize: 25.0), //Font, Font size | |
.strikethroughStyle: 3, //Width of strikethrough line | |
.strikethroughColor: UIColor.red, //Color of strikethrough line | |
] |
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
struct ColorManager { | |
static let mainRedColor = UIColor(red: 1, green: 0.28, blue: 0.29, alpha: 1) | |
static let mainWhiteColor = UIColor.white | |
static let mainBlueColor = UIColor(red: 0.51, green: 0.76, blue: 0.83, alpha: 1) | |
static let petBorderCellColor = UIColor(red: 0.85, green: 0.93, blue: 0.95, alpha: 1) | |
static let mainBlueBackground = UIColor(red: 0.9, green: 0.95, blue: 0.96, alpha: 1) | |
static let mainGrayColor = UIColor.darkGray | |
static let lightestGrayColor = UIColor(red: 0.85, green: 0.85, blue: 0.83, alpha: 1) | |
static let btnRedDefault = UIColor(red: 1, green: 0.28, blue: 0.29, alpha: 1) | |
static let btnRedHighlighted = UIColor(red: 0.9, green: 0.08, blue: 0.09, alpha: 1) |
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
R.font.sfuiDisplayBold(size: 14.0) | |
R.color.alertBG() | |
R.nib.authChooseRoleViewController | |
R.file.configurationPlist() | |
R.storyboard.launchScreen() |
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
typealias Text = R.string.localizable | |
typealias Image = R.image | |
typealias Color = R.color | |
typealias PlistFetcher = R.file | |
typealias Font = R.font |
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
guard let url = URL(string: "https://www.google.com/"), //Create non-optional URL to our website | |
UIApplication.shared.canOpenURL(url) else { //Check if app can open this URL | |
return | |
} | |
UIApplication.shared.open(url) //Open our website in Safari |
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
let yourNumber = "+1 999 999 9999" //Your needed phone | |
guard let number = URL(string: "tel://" + yourNumber), //Check if phone non-optional and app can open this URL | |
UIApplication.shared.canOpenURL(number) else { return } | |
UIApplication.shared.open(number) //Call your phone |
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
// MARK: Change cornerRadius UIView | |
view.layer.cornerRadius = 5 | |
// MARK: Set shadow to UIView | |
view.layer.shadowOffset = CGSize(width: 5, height: 5) | |
view.layer.shadowOpacity = 0.7 | |
view.layer.shadowRadius = 5 | |
view.layer.shadowColor = UIColor.green.cgColor | |
// MARK: Set border to UIView |
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
var sublayers: [CALayer]? - //Array of all sublayers in current layer | |
var superlayer: CALayer? - //Parent layer if exist | |
func addSublayer(CALayer) - //Add new sublayer | |
func removeFromSuperlayer() - //Remove layer from superLayer | |
func insertSublayer(CALayer, at: UInt32) - //Insert new layer on specific index |
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
// MARK: Creation of sublayer1 | |
let sublayer1 = CALayer() | |
sublayer1.frame = CGRect(x: 20, y: 20, width: 30, height: 30) | |
sublayer1.backgroundColor = UIColor.red.cgColor | |
// MARK: Creation of sublayer2 | |
let sublayer2 = CALayer() | |
sublayer2.frame = CGRect(x: 80, y: 80, width: 40, height: 40) | |
sublayer2.backgroundColor = UIColor.green.cgColor |
OlderNewer