MFNoticeLabel 0.1.1

MFNoticeLabel 0.1.1

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Jun 2016
SPMSupports SPM

Maintained by Mateusz Fidos.



MFNoticeLabel

Example

To run the example project, clone the repo, open and run Example scheme.

Requirements

ARC
iOS8

Installation

MFNoticeLabel is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "MFNoticeLabel"

Usage

Start with some importing:

import MFNoticeLabel

Creat and customize your label: (add notice message and define selection type)

label.frame = CGRect(x: 0, y: 0, width: 300, height: 40)
label.center = self.view.center
label.textAlignment = .Center
label.text = "Something something"
label.noticeMessage = "Longer than something something because it is a description and stuff"
label.textColor = UIColor.blueColor()
label.noticeSelectionType = MFNoticeLabelSelectionType.LongPress
label.longPressDelegate = self
view.addSubview(label)

Be sure to properly define selection type you want to use:

label.noticeSelectionType = MFNoticeLabelSelectionType.LongPress

You can conform to either long press (see above) or tap delegate protocols:

public protocol MFNoticeLabelTapDelegate: class
{
func didSelectLabel(text: String)
}

public protocol MFNoticeLabelLongPressDelegate: class
{
func didLongPressLabel(text: String)
func longPressEnded()
}

Or you can define tap handler or long press start/end handlers

public func handleTap(handler:(String) -> ()){}
public func handleLongPressStarted(handler:(String) -> ()){}
public func handleLongPressEnded(handler:() -> ()){}

You can either use your own way of presenting notice message or you can use build in alert-like controller (a bit customizable: background color, alert title label and alert description label were made public)

let button2 = MFNoticeAlertButton(title: "Dismiss", style: MFNoticeAlertButtonStyle.Cancel, action: {
self.dismissViewControllerAnimated(true, completion: nil)
})

let button1 = MFNoticeAlertButton(title: "Ok", style: MFNoticeAlertButtonStyle.Default, action: {
self.dismissViewControllerAnimated(true, completion: nil)
})

let alertVC = MFNoticeAlertController(title: "Some title", description: "A little bit of text just to give you a taste on what it may look like, little bit of text just to give you a taste on what it may look like", image: UIImage(named: "phone"))

alertVC.addButtons([button1, button2])

self.presentViewController(alertVC, animated: true, completion: nil)

Author

Mateusz Fidos, [email protected]

License

MFNoticeLabel is available under the MIT license. See the LICENSE file for more info.