Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

Attia Mo AttiaMo

🎯
Focusing
View GitHub Profile
View Check on screen size
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
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
//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
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)!
}
}
@AttiaMo
AttiaMo / Extension.swift
Last active Dec 19, 2017
Extension file
View Extension.swift
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)
}
}
@AttiaMo
AttiaMo / AppDelegate.swift
Created Nov 12, 2017
Setup global appearance of custom font in your whole app.
View AppDelegate.swift
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
}
@AttiaMo
AttiaMo / AppDelegate.swift
Last active Oct 13, 2019
Find fonts name
View AppDelegate.swift
for family: String in UIFont.familyNames
{
print("\(family)")
for names: String in UIFont.fontNames(forFamilyName: family)
{
print("== \(names)")
}
}
You can’t perform that action at this time.