无标题文章

####一、可翻页的卡片式弹出框的实现

1.**首先我们需要自定义绘制一个取消按钮**

========

* 新建一个类`QKInfoCardCloseButton`继承自UIButton

========

* 添加属性```@property (nonatomic) UIColor *buttonStrokeColor; ```

=======

* 实现方法`-(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];

}

```

=======

* 设置背景色`backgroundColor` 设置 `self.showsTouchWhenHighlighted = YES;`

```objective-c

- (void)setUp {

self.backgroundColor = [UIColor whiteColor];

self.showsTouchWhenHighlighted = YES;

}

```

=======

* 重写`- (void)drawRect:(CGRect)rect`来绘制按钮

2.**新建一个类`QKInfoCardContainerView`继承自UIView用来实现显示区域**

* 添加以下属性

=====

```objective-c

@property (assign, nonatomic) CGFloat cornerRadius;//显示区域的圆角

@property (strong, nonatomic) UIColor *containerBackgroundColor;//显示区域的背景色

@property (strong, nonatomic) UIColor *closeButtonTintColor;//关闭按钮的线条颜色

@property (strong, nonatomic) UIColor *closeButtonBackgroundColor;//关闭按钮的背景色

@property (strong, nonatomic) NSArray *containtViews;//用来展示的子控制器

```

* 添加私有属性

```objective-c

@implementation QKInfoCardContainerView {

QKInfoCardCloseButton *_closeButton;//关闭按钮

UIView *_containerView;//展示视图

UIScrollView *_scrollView;

}

```

* 同样去实现三个构造方法

===

```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];

}

```

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • ####一、可翻页的卡片式弹出框的实现 1.**首先我们需要自定义绘制一个取消按钮** ======== * 新建...
    15c71b2c9951阅读 193评论 0 1
  • 1、设置UILabel行间距 NSMutableAttributedString*attrString=[[NSM...
    iOS祎阅读 2,190评论 0 0
  • 转至元数据结尾创建: 董潇伟,最新修改于: 十二月 23, 2016 转至元数据起始第一章:isa和Class一....
    40c0490e5268阅读 1,757评论 0 9
  • 【2017年最新】☞ iOS面试题及答案 设计模式是什么? 你知道哪些设计模式,并简要叙述? 设计模式是一种编码经...
    紫色冰雨阅读 621评论 0 1
  • 坚持冥想100天,养成习惯,让冥想与自己的生活融为一体。 打卡第22天 时长:16分钟 感悟:在凳子上坐直冥想。本...
    爱做瑜伽的小兔子阅读 642评论 2 4