Simplistic custom message box for your view controllers without hassle and it can also jiggle!
##Requirements
- iOS 7.0+ (8.0+ recommended)
- Swift 1.2
- Xcode 6.3
##Installation
###Carthage
Carthage is a decentralized dependency manager that automates the process of adding frameworks to your Cocoa application.
You can install Carthage with Homebrew using the following command:
$ brew update
$ brew install carthage
To integrate TDGMessageKit into your Xcode project using Carthage, specify it in your Cartfile
:
github "tdgunes/TDGMessageKit" == 1.0
###Manually
If you prefer to not use a depedency manager, you can integrate TDGMessageKit manually into your project.
####Embedded Framework
- Add TDGMessageKit as a submodule by opening the Terminal,
cd
-ing into your top-level project directory, and entering the following command:
$ git submodule add https://github.com/tdgunes/TDGMessageKit.git
-
Open the new
TDGMessageKit
folder, and drag theTDGMessageKit.xcodeproj
into 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
TDGMessageKit.xcodeproj
in 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. -
Select the top
TDGMessageKit.framework
for iOS -
And that's it!
The
TDGMessageKit.framework
is 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.
####Source File
For application targets that do not support embedded frameworks, such as iOS 7, TDGMessageKit can be integrated by adding all the Swift files located inside the TDGMessageKit
directory (TDGMessageKit/*.swift | TDGMessageKit/*.xib
) directly into your project. Note that you will no longer need to import TDGMessageKit
since you are not actually loading a framework. Additionally, any of the calling conventions described in the 'Usage' section with the TDGMessageKit
prefix would instead omit it (for example, TDGMessageKit.TDGMessageBox
becomes TDGMessageBox
), since this functionality is incorporated into the top-level namespace.
##Usage
###Showing a MessageBox
import TDGMessageKit
var messageBox = TDGMessageBox(orientation: .Bottom)
messageBox.titleLabel.text = "TitleLabel Example Text"
messageBox.bodyLabel.text = "BodyLabel Example Text"
messageBox.addTo(self.view)
messageBox.toggle()
###Supported Orientations
You can display a message box from top or from bottom. Supported orientations:
TDGMessageBox.Orientation.Bottom
TDGMessageBox.Orientation.Top
###Display Methods
.toggle()
method hides or shows messsage box according to the current state of the view..hide()
.show()
.focus()
makes a cute jiggle animation.
###UI Components
titleLabel:UILabel
bodyLabel:UILabel
imageView:UIImageView
###Touchable
On default every TDGMessageBox comes with a UITapGestureRecognizer
built-in. If you want to attach a callback to taps to the message box, you can simply:
messageBox.onTap = {
println("Got tapped!")
}
###Get White
Regularly, you may want to switch image and labels to white, instead of default black. You can do this simply by:
messageBox.whiten()
If you're starting a new project in Swift, and don't want to waste time on making a reusable message box.
Got influenced by this.
This small documentation is highly adapted from Alamofire. Thanks for great work!
TDGMessageKit is released under the MIT license. See LICENSE for details.