天天看点

PXAlertView——可用来替代UIAlertView,iOS7风格。可自行定制

  • 关键字:UIAlertView,iOS7
  • 代码类库:其他(Others)
  • GitHub链接:https://github.com/alexanderjarvis/PXAlertView

PXAlertView可以用来替代UIAlertView ,它采用的是iOS 7的风格,拥有基于block的API,它还可以自己定制UI风格以及增加定制的views。

效果图:

PXAlertView——可用来替代UIAlertView,iOS7风格。可自行定制

特色

使用简单的block syntax来取代delegates

适合iOS 7de UIAlertView的动画

可以任意定制

可以在title的底部增加自己的UIView

安装

将下行加入CocoaPods的Podfile

pod 'PXAlertView', '~> 0.0.2'

或者复制附件中的PXAlertView.h和.m文件到工程中去。

使用方法

查看PXAlertView.h文件获取完整的API。如下:

?

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52

//

//  PXAlertView.h

//  PXAlertViewDemo

//

//  Created by Alex Jarvis on 25/09/2013.

//  Copyright (c) 2013 Panaxiom Ltd. All rights reserved.

//

@import

UIKit;

@interface

PXAlertView : UIView

@property

(

nonatomic

, getter = isVisible)

BOOL

visible;

+ (PXAlertView *)showAlertWithTitle:(

NSString

*)title;

+ (PXAlertView *)showAlertWithTitle:(

NSString

*)title

message:(

NSString

*)message;

+ (PXAlertView *)showAlertWithTitle:(

NSString

*)title

message:(

NSString

*)message

completion:(

void

(^) (

BOOL

cancelled))completion;

+ (PXAlertView *)showAlertWithTitle:(

NSString

*)title

message:(

NSString

*)message

cancelTitle:(

NSString

*)cancelTitle

completion:(

void

(^) (

BOOL

cancelled))completion;

+ (PXAlertView *)showAlertWithTitle:(

NSString

*)title

message:(

NSString

*)message

cancelTitle:(

NSString

*)cancelTitle

otherTitle:(

NSString

*)otherTitle

completion:(

void

(^) (

BOOL

cancelled))completion;

+ (PXAlertView *)showAlertWithTitle:(

NSString

*)title

message:(

NSString

*)message

cancelTitle:(

NSString

*)cancelTitle

otherTitle:(

NSString

*)otherTitle

contentView:(UIView *)view

completion:(

void

(^) (

BOOL

cancelled))completion;

@end

例子:

?

1 2 3 4 5 6 7 8 9 10 11

[PXAlertView showAlertWithTitle:@

"The Matrix"

message:@

"Pick the Red pill, or the blue pill"

cancelTitle:@

"Blue"

otherTitle:@

"Red"

completion:^(

BOOL

cancelled) {

if

(cancelled) {

NSLog

(@

"Cancel (Blue) button pressed"

);

}

else

{

NSLog

(@

"Other (Red) button pressed"

);

}

}];

特色

iOS 7风格

支持动态指定 AlertView: default/dark的风格

支持增加多个按钮

下载附件: 

PXAlertView——可用来替代UIAlertView,iOS7风格。可自行定制

 PXAlertView-master.zip (406 K) 下载次数:62