首页 > 其他 > 详细

如何写自定义的AlertView

时间:2015-10-15 23:26:42      阅读:143      评论:0      收藏:0      [点我收藏+]

如何写自定义的AlertView

技术分享

 

效果

技术分享

技术分享

 

说明

考虑到后面的可定制性以及可维护性,本人用AbstractAlertView定义了AlertView抽象的基类,实现通过子类来完成.

注:这只是粗略的写了一个实现,并没有考虑到代码的合理性以及精确性.

 

源码

https://github.com/YouXianMing/AbstractAlertView

//
//  AbstractAlertView.h
//  AlertViewDemo
//
//  Created by YouXianMing on 15/10/15.
//  Copyright © 2015年 ZiPeiYi. All rights reserved.
//

#import <UIKit/UIKit.h>

@class AbstractAlertView;

@protocol AlertViewEventDelegate <NSObject>

@required
/**
 *  代理执行的事件
 *
 *  @param alertView alertView
 *  @param index     按钮编号
 */
- (void)alertView:(AbstractAlertView *)alertView buttonEventIndex:(NSInteger)index;

@end

@interface AbstractAlertView : UIView

/**
 *  响应事件的代理
 */
@property (nonatomic, weak)   id <AlertViewEventDelegate> delegate;

/**
 *  插入后显示的view
 */
@property (nonatomic, weak)   UIView   *insertView;

/**
 *  标题
 */
@property (nonatomic, strong) NSString *title;

/**
 *  副标题
 */
@property (nonatomic, strong) NSString *subTitle;

/**
 *  信息
 */
@property (nonatomic, strong) NSString *message;

/**
 *  按钮标题数组
 */
@property (nonatomic, strong) NSArray <NSString *> *buttonTitlesArray;

/**
 *  显示(在show的时候构建出view)
 */
- (void)show;

/**
 *  隐藏
 */
- (void)hide;

@end
//
//  AbstractAlertView.m
//  AlertViewDemo
//
//  Created by YouXianMing on 15/10/15.
//  Copyright © 2015年 ZiPeiYi. All rights reserved.
//

#import "AbstractAlertView.h"

@implementation AbstractAlertView

- (void)show {

}

- (void)hide {

}

@end

 

细节

技术分享

 

如何写自定义的AlertView

原文:http://www.cnblogs.com/YouXianMing/p/4883830.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!