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! :)
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.