All Projects → Lasithih → Lihalert

Lasithih / Lihalert

Licence: mit
Advance animated alerts for iOS written in Swift

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Lihalert

Nativepopup
Clone of Apple iOS App's feedback popup, and easily customizable.
Stars: ✭ 247 (+626.47%)
Mutual labels:  ios-ui, ios-animation, alert
BalloonPopup
Forget Android Toast! BalloonPopup displays a round or squared popup and attaches it to a View, like a callout. Uses the Builder pattern for maximum ease. The popup can automatically hide and can persist when the value is updated.
Stars: ✭ 32 (-5.88%)
Mutual labels:  alert, alertview
circularProgressBar
This repo contains a demo app for circularProgressBar.swift
Stars: ✭ 17 (-50%)
Mutual labels:  ios-animation, ios-ui
Kdintroview
Stars: ✭ 300 (+782.35%)
Mutual labels:  ios-ui, ios-animation
Rhplaceholder
Show pleasant loading view for your users 😍
Stars: ✭ 238 (+600%)
Mutual labels:  ios-ui, ios-animation
AlertKit
🚨 SwiftUI alerts (and action sheets) done right
Stars: ✭ 60 (+76.47%)
Mutual labels:  alert, alertview
Cariocamenu
The fastest zero-tap iOS menu.
Stars: ✭ 785 (+2208.82%)
Mutual labels:  ios-ui, ios-animation
Wobbly
(Animate CSS) animations for iOS. An easy to use library of iOS animations. As easy to use as an easy thing.
Stars: ✭ 150 (+341.18%)
Mutual labels:  ios-ui, ios-animation
Marqueelabel
Charles Powell
Stars: ✭ 3,741 (+10902.94%)
Mutual labels:  ios-ui, ios-animation
Popupdialog
A simple, customizable popup dialog for iOS written in Swift. Replaces UIAlertController alert style.
Stars: ✭ 3,709 (+10808.82%)
Mutual labels:  alert, alertview
Cfnotify
A customizable framework to create draggable views
Stars: ✭ 490 (+1341.18%)
Mutual labels:  alert, alertview
Pvview
A small library that helps you to make an amazing parallax view
Stars: ✭ 227 (+567.65%)
Mutual labels:  ios-ui, ios-animation
Iosproject
iOS project of collected some demos for iOS App, use Objective-C
Stars: ✭ 5,357 (+15655.88%)
Mutual labels:  ios-ui, ios-animation
TezAlertView
Custom singleton alertView with block completion.
Stars: ✭ 17 (-50%)
Mutual labels:  alert, alertview
Mycoretextlabel
图文混排 , 实现图片文字混排 , 可显示常规链接比如网址,@,#话题#,手机号 , 邮箱号等 , 可以自定义链接字,设置关键字高亮等功能 . 适用于微博,微信,IM聊天对话等场景 . 实现这些功能仅用了几百行代码,耦合性也较低
Stars: ✭ 192 (+464.71%)
Mutual labels:  ios-ui, ios-animation
Iosproject
IOS综合项目,完善的框架,路由模块化设计,集成科大讯飞SDK方便iOS基本输入控件实现语音辅助输入,UI效果参照京东APP,JS与OC交互,ionic跨平台开发,MQTT 协议,即时通讯协议,视屏播放,跑马灯效果 仿美团地图定位,城市收索, 友盟分享,基础动画 增加FCUIID帮助类,引导页功能模块,照片上传 ,UIView自定义导航栏,文件下载,Masonry 案例,fmdb,数据库,sqlite,百度地图,二维码,照片上传,照片上传有进度,列表倒计时,H5和原生交互,自定义各种弹框,常见表单类型,人脸识别,列表加载图片,列表拖拽,日历操作,导航条渐变,核心动画,动画特效等等
Stars: ✭ 291 (+755.88%)
Mutual labels:  ios-ui, ios-animation
Skeletonview
☠️ An elegant way to show users that something is happening and also prepare them to which contents they are awaiting
Stars: ✭ 10,804 (+31676.47%)
Mutual labels:  ios-ui, ios-animation
Bpstatusbaralert
BPStatusBarAlert is a library that allows you to easily make text-based alert that appear on the status bar and below navigation bar.
Stars: ✭ 129 (+279.41%)
Mutual labels:  ios-ui, alertview
Sclalertview
Beautiful animated Alert View. Written in Objective-C
Stars: ✭ 3,426 (+9976.47%)
Mutual labels:  alert, alertview
Alerttransition
AlertTransition is a extensible library for making view controller transitions, especially for alert transitions.
Stars: ✭ 565 (+1561.76%)
Mutual labels:  alert, alertview

LIHAlert

LIHAlert

LIHAlert provides animated banners for iOS. Updated to Swift 3

general custom

Version License Platform

Demo Project

The LIHAlert workspace contains a demo project, also used for developments.

Requirements

Xcode 7+

Installation

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

pod "LIHAlert"

or

Copy the LIHAlert folder into your project.

For the swift 2 version

pod 'LIHAlert', '~> 1.1.0'

Usage

Import the module using

    import LIHAlert

To run the example project, clone the repo, and run pod install from the Example directory first.

Templates

LIHAlert contains some predefined alert templates for each Alert type.

You can use following code snippets to use them.

1. Text Banner

text

    var textAlert: LIHAlert?
    override func viewDidLoad() {
        super.viewDidLoad()
        self.textAlert = LIHAlertManager.getTextAlert("Sample Message")
        self.textAlert?.initAlert(self.view)
    }
    func showBanner(sender: AnyObject) {
        self.textAlert?.show(nil, hidden: nil)
    }

Call showBanner() function to show the banner

2. Success Alert

success

var successAlert: LIHAlert?
override func viewDidLoad() {
    super.viewDidLoad()
    self.successAlert = LIHAlertManager.getSuccessAlert(message: "Successfully subscribed")
    self.successAlert?.initAlert(self.view)
}
func showBanner(sender: AnyObject) {
    self.successAlert?.show(nil, hidden: nil)
}

To change the icon,

    successAlert?.icon = UIImage(named:"imageName")
3. Error Alert

error

var errorAlert: LIHAlert?
override func viewDidLoad() {
    super.viewDidLoad()
    self.errorAlert = LIHAlertManager.getErrorAlert(message: "Failed. Please try again")
    self.errorAlert?.initAlert(self.view)
}
func showBanner(sender: AnyObject) {
    self.errorAlert?.show(nil, hidden: nil)
}

To change the icon,

    successAlert?.icon = UIImage(named:"imageName")
4. Text with title

textwithtitle

    var textWithTitleAlert: LIHAlert?
    override func viewDidLoad() {
        super.viewDidLoad()
        self.textWithTitleAlert = LIHAlertManager.getTextWithTitleAlert("This is The Title", message: "This is a sample message.")
        self.textWithTitleAlert?.initAlert(self.view)
    }
    func showBanner(sender: AnyObject) {
        self.textWithTitleAlert?.show(nil, hidden: nil)
    }
5. Loading Alert

This is a banner with a text and an activity indicator. This is not an auto close banner. You have to hide it when the process is finished.

processing

    var processingAlert: LIHAlert?
    override func viewDidLoad() {
        super.viewDidLoad()
        self.processingAlert = LIHAlertManager.getProcessingAlert("Fetching data...")
        self.processingAlert?.initAlert(self.view)
    }
    func showBanner(sender: AnyObject) {
        self.processingAlert?.show(nil, hidden: nil)
    }
    override hideBanner(sender: AnyObject) {
        self.processingAlert?.hide(nil)
    }

Call showBanner() function to show the banner and hideBanner() to hide the banner. To change the activity indicator style,

    processingAlert?.activityIndicatorStyle = UIActivityIndicatorViewStyle.WhiteLarge
6. Text with a button Alert

This alert contains a button along with a text. More suitable for notifying important messages to user. withbutton

    var textWithButtonAlert: LIHAlert?
    override func viewDidLoad() {
        super.viewDidLoad()
        self.textWithButtonAlert = LIHAlertManager.getTextWithButtonAlert("You have successfully subscribed for the monthly newsletter", buttonText: "Dismiss")
        self.textWithButtonAlert?.initAlert(self.view)
    }
    func showBanner(sender: AnyObject) {
        textWithButtonAlert?.show(nil, hidden: nil)
    }

Call showBanner() function to show the banner. Implement LIHAlertDelegate for button click events.

class ViewController: LIHAlertDelegate {
    func buttonPressed(button: UIButton) {
        print(“You have pressed the button”)
        self.textWithButtonAlert?.hideAlert(nil)
    }
}
7. Text with two buttons Alert

This alert contains two buttons along with a text.

twobuttons

    var textWithTwoButtonsAlert: LIHAlert?

    override func viewDidLoad() {
        super.viewDidLoad()
        self.textWithTwoButtonsAlert = LIHAlertManager.getTextWithTwoButtonsAlert("Do you want to subscribe for the monthly newsletter?", buttonOneText: "Subscribe", buttonTwoText: "Cancel")
        self.textWithTwoButtonsAlert?.initAlert(self.view)
    }
    func showBanner(sender: AnyObject) {
        textWithTwoButtonsAlert?.show(nil, hidden: nil)
    }

Call showBanner() function to show the banner. Implement LIHAlertDelegate for button click events.

class ViewController: LIHAlertDelegate {
    func buttonOnePressed(button: UIButton) {
        self.textWithTwoButtonsAlert?.hideAlert({ () -> () in
            self.successAlert?.show(nil, hidden: nil)
        })
    }
    func buttonTwoPressed(button: UIButton) {
        self.textWithTwoButtonsAlert?.hideAlert(nil)
    }
}
8. Custom View Alert

You can specify any view to act as the banner.

customview

    var customViewAlert: LIHAlert?

    override func viewDidLoad() {
        super.viewDidLoad()
    //In this case I am using an ImageView as the banner
        let customView = UIImageView(frame: CGRectMake(0.0, 64.0, 100, 50))
        customView.image = UIImage(named: "customViewImage")
        self.customViewAlert = LIHAlertManager.getCustomViewAlert(customView)
        self.customViewAlert?.initAlert(self.view)
    }
    func showBanner(sender: AnyObject) {
        self.customViewAlert?.show(nil, hidden: nil)
    }

How to embed a view controller

custom_list

var customViewAlert: LIHAlert?
override func viewDidLoad() {
    super.viewDidLoad()
    let vc = (self.storyboard?.instantiateViewController(withIdentifier: "TableVc"))!
    self.customViewAlert = LIHAlertManager.getCustomViewAlert(customView: vc.view)
    self.customViewAlert?.initAlert(self.view)
    self.addChildViewController(vc)
    vc.didMove(toParentViewController: self)
}
func showBanner(sender: AnyObject) {
    self.customViewAlert?.show(nil, hidden: nil)
}

See 'CustomAlertsViewController' for more embed view controller examples

How to create your own banner

    let alertTextAlert: LIHAlert = LIHAlert()
    alertTextAlert.alertType = LIHAlertType.Text
    alertTextAlert.contentText = message
    alertTextAlert.alertColor = UIColor(red: 102.0/255.0, green: 197.0/255.0, blue: 241.0/255.0, alpha: 1.0)
    alertTextAlert.alertHeight = 50.0
    alertTextAlert.alertAlpha = 1.0
    alertTextAlert.autoCloseEnabled=true
    alertTextAlert.contentTextColor = UIColor.whiteColor()
    alertTextAlert.hasNavigationBar = true
    alertTextAlert.paddingTop = 0.0
    alertTextAlert.animationDuration = 0.35
    alertTextAlert.autoCloseTimeInterval = 1.5
ALert Types
    enum LIHAlertType {
            case Custom, Text, TextWithLoading, TextWithIcon, TextWithButton, TextWithTwoButtons, TextWithTitle
    }

List of all properties

    //delegates
    public var delegate: LIHAlertDelegate?
    
    //Title
    public var titleLabel: UILabel?
    public var titleText: String //Default is "Sample Title"
    public var titleTextColor: UIColor //Default is UIColor.blackColor()
    public var titleTextFont: UIFont?
    public var titleTextFontSize: CGFloat?
    public var titleTextNumberOfLines: Int //Default is 1 
    
    
    //Content Text
    public var contentLabel: UILabel?
    public var contentText: String //Default is "Sample Content"
    public var contentTextColor: UIColor //Default is UIColor.blackColor()
    public var contentTextFont: UIFont?
    public var contentTextNumberOfLines: Int //Default is 2
    
    //TextWithLoading
    public var activityIndicatorStyle: UIActivityIndicatorViewStyle //Default is UIActivityIndicatorViewStyle.White
    
    //Icon
    public var  iconImageView: UIImageView?
    public var  icon: UIImage?
    
    //OneButton
    public var  button_textWithButton: UIButton?
    public var  buttonText: String //Default is "Dismiss"
    public var  buttonColor: UIColor //Default is UIColor.blueColor()
    public var  buttonTextColor: UIColor //Default is UIColor.whiteColor()
    public var  buttonFont: UIFont?
    public var  buttonBordercolor: UIColor //Default is UIColor.whiteColor()
    public var  buttonBorderWidth: CGFloat //Default is 1.0 
    public var  buttonCornerRadius: CGFloat //Default is 3.0
    public var  buttonWidth: CGFloat?
    
    //TWO BUTTONS
        //ButtonOne
    public var  buttonOne_textWithButton: UIButton?
    public var  buttonOneText: String //Default is "Dismiss"
    public var  buttonOneColor: UIColor //Default is UIColor.blueColor()
    public var  buttonOneTextColor: UIColor //Default is UIColor.whiteColor() 
    public var  buttonOneFont: UIFont?
    public var  buttonOneBordercolor: UIColor //Default is UIColor.whiteColor()
    public var  buttonOneBorderWidth: CGFloat //Default is 1.0
    public var  buttonOneCornerRadius: CGFloat //Default is 3.0
    
        //ButtonTwo
    public var  buttonTwo_textWithButton: UIButton?
    public var  buttonTwoText: String //Default is "Dismiss"
    public var  buttonTwoColor: UIColor //Default is UIColor.blueColor()
    public var  buttonTwoTextColor: UIColor //Default is UIColor.whiteColor()
    public var  buttonTwoFont: UIFont?
    public var  buttonTwoBordercolor: UIColor //Default is UIColor.whiteColor()
    public var  buttonTwoBorderWidth: CGFloat //Default is 1.0
    public var  buttonTwoCornerRadius: CGFloat //Default is 3.0
    
    //AlertView
    public var  alertView: UIView?
    public var  alertColor: UIColor //Default is UIColor.grayColor()
    public var  alertAlpha: CGFloat //Default is 1.0
    public var  alertHeight:CGFloat //Default is 75.0
    public var  paddingLeft: CGFloat //Default is 0.0
    public var  paddingTop: CGFloat //Default is 0.0
    public var  animationDuration: NSTimeInterval //Default is 0.5
    public var  alertType: LIHAlertType //Default is LIHAlertType.Text
    public var  autoCloseEnabled: Bool //Default is true
    public var  autoCloseTimeInterval: Double //Default is 3.0
    public var  hasNavigationBar: Bool //Default is false
    public var  touchBackgroundToDismiss: Bool //default is false
    public var  dimsBackground: Bool //default is false
    public var backgroundDimOpacity: CGFloat //default is 0.4

Use the completion callbacks

    //when showing an auto hiding banner
    lihAlert?.show({ () -> () in
                //alert showed
            }, hidden: { () -> () in
                //alert hidden
        })
        
        //when hiding a banner
        lihAlert?.hideAlert({ () -> () in
            //Banner hidden
        })

Known Issues

1. Top margin

In some projects the alert may appear with a margin on top. Hopefully this will be fixed in the next release. Until then use the following solution.

Solution

Even the navigation bar is there, set it to false.

alert.hasNavigationBar = false

ChangeLog

v2.1.1

Dim background, Touch background to dismiss

v2.0.4

Objective-C support(beta)

v2.0.2

Embed view controller support

v2.0.0

Updated to Swift 3

v1.1.0

Fixed an issue - Alerts comes to the top when it appears

v1.0.0

Banner templates
  • Text only
  • Text with a title
  • Text with an ActivityIndicator
  • Text with an icon
  • Text with a button
  • Text with two buttons
  • Custom view banner

Author

Lasith Hettiarachchi, [email protected]

License

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].