[翻译] CNPPopupController

简介:

CNPPopupController

CNPPopupController is a simple and versatile class for presenting a custom popup in a variety of fashions. It includes a many options for controlling how your popup appears and behaves.

Please feel free to contribute to this project, open issues, make suggestions and submit pull-requests. If you use this project in your app, let me know. I'd love to see what you do with it.

CNPPopupController是一个简单的用于提示显示用的view,提供几种流行的显示模式。他包含了很多的设置选项供你定制他的样式。

欢迎你免费使用这个项目,并给我提出需求以及建议,或者自己改进他。如果你的项目中用了这份代码,如果你能告诉我,我将感激不尽。

 

 

Installation

Available in Cocoa Pods

pod 'CNPPopupController'

支持Cocoa Pods,

pod 'CNPPopupController' 即可安装

Usage

(See sample Xcode project in /CNPPopupControllerExample)

在Xcode project in /CNPPopupControllerExample查看使用样例

Creating a Popup

Create a popup with custom animations and behaviors. Customizations can also be accessed via properties on the CNPPopupTheme instance:

创建一个popup,支持自定义的动画方式。你可以通过主题实例中的参数来定制样式:

- (instancetype)initWithTitle:(NSAttributedString *)popupTitle
                 contents:(NSArray *)contents
              buttonItems:(NSArray *)buttonItems
   destructiveButtonItem:(CNPPopupButtonItem *)destructiveButtonItems;

popupTitle only accepts an NSAtributedString object.

popupTitle只支持富文本对象。

contents only accepts an array of NSAttributedString and UIImage objects.

contents只支持富文本以及图片对象。

buttonItems only accepts an array of CNPPopupButtonItem objects.

buttonItems只支持CNPPopupButtonItem对象数组。

destructiveButtonItem only accepts an CNPPopupButtonItem object.

destructiveButtonItem只支持CNPPopupButtonItem对象。


Note: You may pass nil for any of the initializer properties when creating the popup, but you must assign a theme to the popup before showing it!

A default theme + [CNPPopupTheme defaultTheme] has been created to help you out.

注意:你创建完了popup后,也许会传递nil给某些属性,但是,你必须在显示这个view之前指定一个主题!

一个默认的主题是 + [CNPPopupTheme defaultTheme] ,你可以用这个方法来帮你。


CNPPopupButtonItem allows you to customize the style for each button on a CNPPopupControllerinstance. You may customize button height, color, border width, corner radius, and border color;

CNPPopupButtonItem允许你修改按钮的样式,你可以修改按钮的高度,颜色,边缘厚度,圆角值以及边缘颜色;

Showing a Popup

- (void)presentPopupControllerAnimated:(BOOL)flag;

Dismissing a Popup

- (void)dismissPopupControllerAnimated:(BOOL)flag;

Customization

CNPPopupTheme instance can be created and assigned to the theme property of aCNPPopupController instance.

@property (nonatomic, strong) UIColor *backgroundColor;

@property (nonatomic, assign) CGFloat cornerRadius;

@property (nonatomic, assign) CGFloat preferredPopupWidth;

@property (nonatomic, assign) CGFloat minimumPopupHeight;

@property (nonatomic, assign) UIEdgeInsets popupContentInsets;

@property (nonatomic, assign) CNPPopupStyle popupStyle;

@property (nonatomic, assign) CNPPopupPresentationStyle presentationStyle;

@property (nonatomic, assign) CNPPopupMaskType maskType;

@property (nonatomic, assign) BOOL shouldDismissOnBackgroundTouch;

@property (nonatomic, assign) CGFloat contentVerticalPadding;

@property (nonatomic, assign) UIStatusBarStyle fullscreenStatusBarStyle;

Notes

Deployment

CNPPopupController works on iOS 7 and iOS 8.

CNPPopupController支持iOS7与iOS8

TODO

  • Add 'blur' option for background mask 添加背景模糊效果
目录
相关文章
|
缓存 API iOS开发
|
iOS开发 Android开发 开发工具
|
C# iOS开发 Perl
|
API 对象存储 iOS开发
|
内存技术 Perl