####一、可翻頁(yè)的卡片式彈出框的實(shí)現(xiàn)
1.**首先我們需要自定義繪制一個(gè)取消按鈕**
========
* 新建一個(gè)類(lèi)`QKInfoCardCloseButton`繼承自UIButton
========
* 添加屬性```@property (nonatomic) UIColor *buttonStrokeColor; ```
=======
* 實(shí)現(xiàn)方法`-(instancetype)initWithFrame:(CGRect)frame;` `-(id)initWithCoder:(NSCoder *)aDecoder` `-(instancetype)init`
```objective-c
-(instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
[self setUp];
}
return self;
}
-(id)initWithCoder:(NSCoder *)aDecoder {
self = [super initWithCoder:aDecoder];
if (self) {
[self setUp];
}
return self;
}
-(instancetype)init {
return [self initWithFrame:CGRectZero];
}
```
=======
* 設(shè)置背景色`backgroundColor` 設(shè)置 `self.showsTouchWhenHighlighted = YES;`
```objective-c
- (void)setUp {
self.backgroundColor = [UIColor whiteColor];
self.showsTouchWhenHighlighted = YES;
}
```
=======
* 重寫(xiě)`- (void)drawRect:(CGRect)rect`來(lái)繪制按鈕
2.**新建一個(gè)類(lèi)`QKInfoCardContainerView`繼承自UIView用來(lái)實(shí)現(xiàn)顯示區(qū)域**
* 添加以下屬性
=====
```objective-c
@property (assign, nonatomic) CGFloat cornerRadius;//顯示區(qū)域的圓角
@property (strong, nonatomic) UIColor *containerBackgroundColor;//顯示區(qū)域的背景色
@property (strong, nonatomic) UIColor *closeButtonTintColor;//關(guān)閉按鈕的線(xiàn)條顏色
@property (strong, nonatomic) UIColor *closeButtonBackgroundColor;//關(guān)閉按鈕的背景色
@property (strong, nonatomic) NSArray *containtViews;//用來(lái)展示的子控制器
```
* 添加私有屬性
```objective-c
@implementation QKInfoCardContainerView {
QKInfoCardCloseButton *_closeButton;//關(guān)閉按鈕
UIView *_containerView;//展示視圖
UIScrollView *_scrollView;
}
```
* 同樣去實(shí)現(xiàn)三個(gè)構(gòu)造方法
===
```objective-c
-(instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
[self setUp];
}
return self;
}
-(id)initWithCoder:(NSCoder *)aDecoder {
self = [super initWithCoder:aDecoder];
if (self) {
[self setUp];
}
return self;
}
-(instancetype)init {
return [self initWithFrame:CGRectZero];
}
```