Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import UIKit
- class CommonUtility {
- class func getPortraitScreenSize() -> CGSize {
- let w = UIScreen.main.bounds.size.width
- let h = UIScreen.main.bounds.size.height
- return CGSize(width: min(w, h), height: max(w, h))
- }
- class func getLandscapeScreenSize() -> CGSize {
- let w = UIScreen.main.bounds.size.width
- let h = UIScreen.main.bounds.size.height
- return CGSize(width: max(w, h), height: min(w, h))
- }
- class func isValidEmail(email:String?) -> Bool {
- let emailRegEx = "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"
- let emailTest = NSPredicate(format:"SELF MATCHES %@", emailRegEx)
- return emailTest.evaluate(with: email)
- }
- class func isValidPassword(password:String?) -> Bool {
- if let pass = password, pass.characters.count >= 0 {
- return true
- }
- return false
- }
- class func isPortrait() -> Bool {
- // return UIScreen.main.bounds.size.height == CommonUtility.getPortraitScreenSize().height
- return UIDevice.current.orientation.isPortrait
- }
- class func isIphone4or5() -> Bool {
- return UIScreen.main.bounds.size.height <= 588.0
- }
- class func subString(input: String, from: Int, to: Int) -> String {
- let start = input.index(input.startIndex, offsetBy: from)
- let end = input.index(input.startIndex, offsetBy: to)
- let range = start..<end
- return input.substring(with: range)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment