iOS第三方庫推薦系列:優秀的彈框與對話框架:LGAlertView

https://juejin.im/entry/5bbac778f265da0ae3440ce5

iOS第三方庫推薦系列:優秀的彈框與對話框架:LGAlertView

閱讀 215

收藏 4

2018-10-08

AMD CPU雲服務器全國首推cloud.tencent.com

Customizable implementation of UIAlertViewController, UIAlertView and UIActionSheet. All in one. You can customize every detail. Make AlertView of your dream! :)

Platform CocoaPods Carthage License

Preview

Default Alert View

 

Default Action Sheet

Blurred Alert View

 

Blurred Action Sheet

Custom Alert View

Custom Action Sheet

Screenshots above are just few examples that you can achieve, you are free to create any other style

Installation

   
   
   

With source code

Download repository, then add LGAlertView directory to your project.

Then import header files where you need to use the library

Objective-C


 

Swift

For swift you need to create bridging header


 

With CocoaPods

CocoaPods is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries in your projects. To install with cocoaPods, follow the "Get Started" section on CocoaPods.

Podfile


 

Then import framework where you need to use the library

Objective-C


 

Swift


 

With Carthage

Carthage is a lightweight dependency manager for Swift and Objective-C. It leverages CocoaTouch modules and is less invasive than CocoaPods. To install with carthage, follow the instruction on Carthage.

Cartfile


 

Then import framework where you need to use the library

Objective-C


 

Swift


 

Usage

Initialization

You have several methods for initialization:

Objective-C


 

Swift


 

More init methods you can find in LGAlertView.h

Setup

You can change properties only before you show alert view, after this to change something is impossible.

Appearance

Instead of change properties for every new alert view, you can use appearance to set them all only once and new alert views will use it by default:

Objective-C


 

Swift


 

Buttons

If you want to set properties for each button individually, you can use method:

Objective-C


 

Swift


 

Enable / Disable

You can enable and disable buttons:

Objective-C


 

Swift


 

Retain Cycle

When you use blocks and if you need to use self inside it, then you need to make weak reference to self to avoid retain cycle:

Objective-C


 

Swift


 

Blur

You can use UIBlurEffect with next properties:


 

For example:

Objective-C


 

Swift


 

If you want to change color of blurred view, use:


 

For example:

Objective-C


 

Swift


 

If you want to change intensity of blurred view, use:


 

For example:


 

Handle actions

To handle actions you can use blocks, delegate or notifications:

Delegate

Objective-C


 

Swift


 

Blocks

Objective-C


 

Swift


 

Notifications


 

More

For more details try Xcode Demo project and see LGAlertView.h

Frameworks

If you like LGAlertView, check out my other useful libraries:

  • LGSideMenuController iOS view controller, shows left and right views by pressing button or gesture.
  • LGPlusButtonsView Customizable iOS implementation of Floating Action Button (Google Plus Button, fab).

License

LGAlertView is released under the MIT license. See LICENSE for details.

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章