View Check on screen size
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 var isIphoneXOrBigger: Bool { | |
// 812.0 on iPhone X, XS. | |
// 896.0 on iPhone XS Max, XR. | |
return UIScreen.main.bounds.height >= 812 | |
} |
View iPhone Notch
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 var hasTopNotch: Bool { | |
if #available(iOS 11.0, tvOS 11.0, *) { | |
// with notch: 44.0 on iPhone X, XS, XS Max, XR. | |
// without notch: 20.0 on iPhone 8 on iOS 12+. | |
return UIApplication.shared.delegate?.window??.safeAreaInsets.top ?? 0 > 20 | |
} | |
return false | |
} |
View ViewController.swift
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
//self.statusLabel.font = UIFont.UIFont(name: "HelveticaNeueW23forSKY-Reg", size: 17) | |
// Or you can replace it with | |
// You can use it for Labels, TextFields, TextViews ..etc | |
self.statusLabel.font = UIFont.appRegularFontWith(size: 17) |
View Extension.swift
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
extension UIFont { | |
class func appRegularFontWith( size:CGFloat ) -> UIFont{ | |
return UIFont(name: "HelveticaNeueW23forSKY-Reg", size: size)! | |
} | |
class func appBoldFontWith( size:CGFloat ) -> UIFont{ | |
return UIFont(name: "HelveticaNeueW23foSKY-Bd", size: size)! | |
} | |
} |
View Extension.swift
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
import Foundation | |
import UIKit | |
extension UILabel { | |
var substituteFontName : String { | |
get { return self.font.fontName } | |
set { | |
if self.font.fontName.range(of:"-Bd") == nil { | |
self.font = UIFont(name: newValue, size: self.font.pointSize) | |
} | |
} |
View AppDelegate.swift
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
func setupGlobalAppearance(){ | |
//global Appearance settings | |
let customFont = UIFont.appRegularFontWith(size: 17) | |
UIBarButtonItem.appearance().setTitleTextAttributes([NSAttributedStringKey.font: customFont], for: .normal) | |
UITextField.appearance().substituteFontName = Constants.App.regularFont | |
UILabel.appearance().substituteFontName = Constants.App.regularFont | |
UILabel.appearance().substituteFontNameBold = Constants.App.boldFont | |
} |
View AppDelegate.swift
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
for family: String in UIFont.familyNames | |
{ | |
print("\(family)") | |
for names: String in UIFont.fontNames(forFamilyName: family) | |
{ | |
print("== \(names)") | |
} | |
} |