Skip to content
/ Kiss Public

iOS snippets that make the code more expressive ! ✔︎

Notifications You must be signed in to change notification settings

s4cha/Kiss

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

Kiss 💋- be more expressive !

This intends to be copy pasted in an iOS Xcode project to facilitate things we do all the time :)

Notifications

Observe

NotificationCenter.default.addObserver(self, selector: #selector(someFunction), name: NSNotification.Name(rawValue:"MyNotification"),object: nil)
observe("MyNotification", #selector(someFunction))

Post

NotificationCenter.default.post(name: NSNotification.Name(rawValue:"MyNotif"), object: nil, userInfo: nil)
notify("MyNotif")

Button Tap event

button.addTarget(self, action: #selector(someFunction), for: .touchUpInside)
bindTap(of: button, #selector(someFunction))

Translations

NSLocalizedString("TranslationKey", comment: "")
localized("TranslationKey")

RGB Colors

UIColor(red: 100 / 255.0, green: 224 / 255.0, blue: 132 / 255.0, alpha: 1)
UIColor(R: 100, G: 224, B: 132)

Navigation

Push

navigationController?.pushViewController(vc, animated: true)
push(vc)

Present

presentViewController(vc, animated: true, completion: nil)
present(vc)

Pop

navigationController?.popViewControllerAnimated(true)
pop()

Dismiss

dismissViewControllerAnimated(true, completion: nil)
dismiss()

Check textfield content

if let t = textfield.text where !t.isEmpty {
    print("not empty")
}
if textfield.hasContent {
    print("not empty")
}

Get keyboard height from Keyboard Notification

if let v = notification.userInfo?[UIKeyboardFrameEndUserInfoKey] as? NSValue {
     let keyboardHeight = v.CGRectValue().size.height
}
notification.keyboardHeight

UIButton background color

button.setBackgroundColor(.blueColor(), forState: .Normal)

About

iOS snippets that make the code more expressive ! ✔︎

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages