https://github.com/s4cha/kiss
iOS snippets that make the code more expressive ! ✔︎
https://github.com/s4cha/kiss
helpers ios kiss sugar swift uikit
Last synced: 6 months ago
JSON representation
iOS snippets that make the code more expressive ! ✔︎
- Host: GitHub
- URL: https://github.com/s4cha/kiss
- Owner: s4cha
- Created: 2016-04-24T18:12:34.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-01-25T13:10:20.000Z (over 8 years ago)
- Last Synced: 2025-04-11T03:59:29.352Z (6 months ago)
- Topics: helpers, ios, kiss, sugar, swift, uikit
- Language: Swift
- Homepage:
- Size: 18.6 KB
- Stars: 6
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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
```swift
NotificationCenter.default.addObserver(self, selector: #selector(someFunction), name: NSNotification.Name(rawValue:"MyNotification"),object: nil)
```
```swift
observe("MyNotification", #selector(someFunction))
```
Post```swift
NotificationCenter.default.post(name: NSNotification.Name(rawValue:"MyNotif"), object: nil, userInfo: nil)
```
```swift
notify("MyNotif")
```## Button Tap event
```swift
button.addTarget(self, action: #selector(someFunction), for: .touchUpInside)
``````swift
bindTap(of: button, #selector(someFunction))
```## Translations
```swift
NSLocalizedString("TranslationKey", comment: "")
``````swift
localized("TranslationKey")
```## RGB Colors
```swift
UIColor(red: 100 / 255.0, green: 224 / 255.0, blue: 132 / 255.0, alpha: 1)
```
```swift
UIColor(R: 100, G: 224, B: 132)
```## Navigation
### Push
```swift
navigationController?.pushViewController(vc, animated: true)
```
```swift
push(vc)
```### Present
```swift
presentViewController(vc, animated: true, completion: nil)
```
```swift
present(vc)
```### Pop
```swift
navigationController?.popViewControllerAnimated(true)
```
```swift
pop()
```### Dismiss
```swift
dismissViewControllerAnimated(true, completion: nil)
```
```swift
dismiss()
```## Check textfield content
```swift
if let t = textfield.text where !t.isEmpty {
print("not empty")
}
```
```swift
if textfield.hasContent {
print("not empty")
}
```## Get keyboard height from Keyboard Notification
```swift
if let v = notification.userInfo?[UIKeyboardFrameEndUserInfoKey] as? NSValue {
let keyboardHeight = v.CGRectValue().size.height
}
``````swift
notification.keyboardHeight
```## UIButton background color
```swift
button.setBackgroundColor(.blueColor(), forState: .Normal)
```