https://github.com/ivanespitiac/swiftutils
Library for iOS developer using swift 4.
https://github.com/ivanespitiac/swiftutils
ios ios-app ios-swift swift swift-library swift4
Last synced: 3 months ago
JSON representation
Library for iOS developer using swift 4.
- Host: GitHub
- URL: https://github.com/ivanespitiac/swiftutils
- Owner: ivanespitiac
- License: mit
- Created: 2020-01-29T00:32:32.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-01-29T01:07:08.000Z (over 5 years ago)
- Last Synced: 2025-03-13T13:13:51.286Z (3 months ago)
- Topics: ios, ios-app, ios-swift, swift, swift-library, swift4
- Language: Swift
- Homepage:
- Size: 33.2 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# swiftUtils
[](https://travis-ci.org/ivanespitiac/swiftUtils)
[](https://cocoapods.org/pods/swiftUtils)
[](https://cocoapods.org/pods/swiftUtils)
[](https://cocoapods.org/pods/swiftUtils)## Example
To run the example project, clone the repo, and run `pod install` from the Example directory first.
## Installation
swiftUtils is available through [CocoaPods](https://cocoapods.org). To install
it, simply add the following line to your Podfile:```ruby
pod 'swiftUtils', :path => '../'
```## Usage
### String
Clean string value:
````
"Hello World".removeSpaces()
````Check if blank:
````
let val = ""
if val.isBlank() {
// TODO
}
````String to Date:
`````
"10/05/2019".toDate(format: "dd/MM/yyyy")
`````Check valid email:
`````
let email = "[email protected]"
if email.isValidEmail() {
// TODO
}
`````Check if String is a number:
`````
let val = "1234 aaa"
if val.isNumber {
// TODO
}
`````Get Localized String by key:
`````
let localized = "label_home".getLozalized()
`````### UITextField & UILabel
Set text localized:
````
textfield.setLocalizedText(key: "label_home")label.setLocalized(key: "label_home")
````Set Hint localized:
````
textfield.setLocalizedHint(key: "label_hint")
````Get text without spaces:
````
val text = textfield.removeSpaces()
````### UIView
Set visible or invisible:
````
let label = UILabel()
label.visible()
label.invisible()
````Set User Interaction:
````
label.interactionEnable()
label.interactionDisable()
````Set corner radius:
````
label.setCornerRadius(radius: 6.0) // all cornerslabel.setCornerRadius([UIRectCorner.topLeft, UIRectCorner.topRight], radius: 6.0) // set corners to change
````Set as a circle:
````
label.setCircle()
````Set border:
````
label.setBorder(with: 2.0, color: UIColor.brown)
````### UIViewController
Show alert without title:
````
controller.showAlertNoTitle(message: "Hello!") // optional completion onTap
````Show alert with title:
````
controller.showAlert(title: "Hello title", message: "Hello message") // optional completion onTap
````Show Question alert:
````
controller.showQuestionMessage(
title: "Hello title",
message: "Hello message",
onAccept: {
// TODO accept
}) {
// TODO Cancel
}
````Present new controller:
````
controller.presentController(
storyboardID: Controller.storyboardID,
storyboardName: "Main",
presentation: .fullScreen)
````Present mail app: (You have to delegate in your controller MFMailComposeViewControllerDelegate if you want to use in that way)
````
controller.requestEmailBuilder(email: "[email protected]")
````### Utils
Get the screen size: (width & height)
````
Utils.screenHeight
Utils.screenWidth
````Check if the app is in debug mode:
````
Utils.isDebug
````## Author
ivanespitiac, [email protected]
## License
swiftUtils is available under the MIT license. See the LICENSE file for more info.