Message is a framework written in Swift that makes it easy for you to show your informational messages
Features
- Standard alert with text fields and buttons
- Standard action sheet with buttons
- Delegation
- Dropdown message
Usage
Simple Alert
Alert(withTitle: "Title", message: "Your message").addTextField { textField in
textField.placeholder = "Placeholder"
}
.addButton(withTitle: "Ok")
.addCancelButton(withTitle: "Close")
.show()Simple ActionSheet
ActionSheet(withTitle: "Title", message: "Your message")
.addButton(withTitle: "Ok")
.addCancelButton(withTitle: "Cancel")
.addDestructiveButton(withTitle: "Destructive")
.show()Using delegate
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
Alert(withTitle: "Title", message: "Your message").addTextField { textField in
textField.placeholder = "Placeholder"
}
.addButton(withTitle: "Ok")
.addCancelButton(withTitle: "Close")
.show(withDelegate: self)
}
}
extension ViewController: AlertDelegate {
func willShow(_ alert: AlertProtocol) {
}
func didShow(_ alert: AlertProtocol) {
}
func willDisappear(_ alert: AlertProtocol) {
}
func didDisappear(_ alert: AlertProtocol) {
}
}Advanced usage
Alert(withMessage: "Message").addButton(withTitle: "Ok").show(after: 1.0)
Alert(withMessage: "Message").show(andCloseAfter: 2.0)
Alert(withMessage: "Message").show(after: 1.0, andCloseAfter: 2.0)Requirements
- iOS 8.0+
- Xcode 8.1, 8.2, 8.3, and 9.0
- Swift 3.0, 3.1, 3.2, and 4.0
Communication
- If you found a bug, open an issue.
- If you have a feature request, open an issue.
- If you want to contribute, submit a pull request.
Installation
CocoaPods
CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:
$ gem install cocoapodsTo integrate Message into your Xcode project using CocoaPods, specify it in your Podfile:
use_frameworks!
target "<Your Target Name>" do
pod "Message"
endThen, run the following command:
$ pod installManually
If you prefer not to use any dependency managers, you can integrate Message into your project manually.
Embedded Framework
-
Open up Terminal,
cdinto your top-level project directory, and run the following command "if" your project is not initialized as a git repository:$ git init
-
Add Message as a git submodule by running the following command:
$ git submodule add https://github.com/incetro/Message.git
-
Open the new
Messagefolder, and drag theMessage.xcodeprojinto the Project Navigator of your application's Xcode project.It should appear nested underneath your application's blue project icon. Whether it is above or below all the other Xcode groups does not matter.
-
Select the
Message.xcodeprojin the Project Navigator and verify the deployment target matches that of your application target. -
Next, select your application project in the Project Navigator (blue project icon) to navigate to the target configuration window and select the application target under the "Targets" heading in the sidebar.
-
In the tab bar at the top of that window, open the "General" panel.
-
Click on the
+button under the "Embedded Binaries" section. -
You will see two different
Message.xcodeprojfolders each with two different versions of theMessage.frameworknested inside aProductsfolder.It does not matter which
Productsfolder you choose from, but it does matter whether you choose the top or bottomMessage.framework. -
Select the top
Message.frameworkfor iOS. -
And that's it!
The
Message.frameworkis automagically added as a target dependency, linked framework and embedded framework in a copy files build phase which is all you need to build on the simulator and a device.
Author
incetro, [email protected]
License
Message is available under the MIT license. See the LICENSE file for more info.
