This file contains hidden or 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 application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { | |
// Assume there are firstView and SecondView in the Main.storyboard | |
// open SecondView | |
window = UIWindow(frame: UIScreen.main.bounds) | |
let storyboad: UIStoryboard = UIStoryboard(name: "Main", bundle: nil) | |
let newViewController = storyboad.instantiateViewController(withIdentifier: "SecondView") as UIViewController | |
window!.rootViewController = newViewController | |
window!.makeKeyAndVisible() | |
return true | |
} |
This file contains hidden or 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 emailRegX = "[A-Z0-9a-z?./_%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}" | |
let emailTest = NSPredicate.init(format: "SELF MATCHES %@", emailRegX) | |
let isEmail = emailTest.evaluate(with: "[email protected]") |
This file contains hidden or 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 UIKit | |
@IBDesignable class CustomBorderView: UIView { | |
@IBInspectable var cornerRadius: CGFloat = 0{ | |
didSet{ | |
self.layer.cornerRadius = cornerRadius | |
} | |
} | |
This file contains hidden or 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
const { width, height } = Dimensions.get('window') | |
const sizeStyle = { | |
width: width, | |
height: height | |
} | |
const styleImage = { | |
flex: 1, | |
justifyContent: 'center', | |
alignItems: 'center' |
This file contains hidden or 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 { Dimensions, Platform } from 'react-native'; | |
export function isIphoneX() { | |
const dimWindow = Dimensions.get('window') | |
return ( | |
Platform.OS === 'ios' && | |
(isIPhoneXSize(dimWindow) || isIPhoneXRMAXSize(dimWindow)) | |
) | |
} | |
export function isIPhoneXSize(window) { |
This file contains hidden or 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
Style: PropTypes.oneOfType( | |
[ | |
PropTypes.number, | |
PropTypes.object, | |
PropTypes.array | |
] | |
) |
This file contains hidden or 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
IBOutlet weak var field1: UITextField! | |
if(field1.text?.isEmpty ?? true) { | |
// field is empty | |
return true | |
} else { | |
// field is NOT empty | |
return false | |
} |
This file contains hidden or 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
DispatchQueue.main.async(execute: { | |
// call any function ex. doSomething() | |
self.doSomething() | |
}) |
This file contains hidden or 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
UIControl().sendAction(#selector(NSXPCConnection.suspend), | |
to: UIApplication.shared, for: nil) |