Latest 0.1.1
Homepage https://github.com/mateuszfidosBLStream/MFNoticeLabel
License MIT
Platforms ios 8.0
Authors

Build Status
Version
License
Platform

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.

Latest podspec

{
    "name": "MFNoticeLabel",
    "version": "0.1.1",
    "summary": "Get a hint?",
    "description": "Just a label that allows you to present some custom alert like controller with extra descritpion on tap or long press",
    "homepage": "https://github.com/mateuszfidosBLStream/MFNoticeLabel",
    "license": "MIT",
    "authors": {
        "Mateusz Fidos": "[email protected]"
    },
    "source": {
        "git": "https://github.com/mateuszfidosBLStream/MFNoticeLabel.git",
        "tag": "0.1.1"
    },
    "social_media_url": "https://twitter.com/@mateuszfidos",
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "MFNoticeLabel/**/*"
}

Pin It on Pinterest

Share This