ThirdPartyView.m
3.9 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
//
// ThirdPartyView.m
// CNLiveUserSystemDemo
//
// Created by iOS on 16/11/18.
// Copyright © 2016年 zhulin. All rights reserved.
//
#import "ThirdPartyView.h"
#define SpaceWidth (KScreenWidth-80*3)/4
@interface ThirdPartyView ()
@property (nonatomic, strong) UIButton *weChatBtn;
@property (nonatomic, strong) UIButton *sinaBtn;
@property (nonatomic, strong) UIButton *qqBtn;
@property (nonatomic, strong) UILabel *thirdpartyLoginLbl;
@property (nonatomic, strong) UIButton *cancelBtn;
@end
@implementation ThirdPartyView
- (instancetype)initWithFrame:(CGRect)frame binding:(BOOL)binding
{
self = [super initWithFrame:frame];
if (self) {
self.backgroundColor = [UIColor blackColor];
[self addSubview:self.sinaBtn];
[self addSubview:self.qqBtn];
[self addSubview:self.weChatBtn];
[self addSubview:self.thirdpartyLoginLbl];
if (binding) {
[self addSubview:self.cancelBtn];
}
}
return self;
}
#pragma mark - ****************action******
- (void)thirdPartyBtnAction:(UIButton *)button
{
if (self.delegate && [self.delegate respondsToSelector:@selector(thirdPartyBtnAction:)]) {
[self.delegate thirdPartyBtnAction:button.titleLabel.text];
}
}
- (void)cancelBtnAction
{
if (self.delegate && [self.delegate respondsToSelector:@selector(cancelThirdView)]) {
[self.delegate cancelThirdView];
}
}
#pragma mark - ****************getter******
- (UILabel *)thirdpartyLoginLbl
{
if (!_thirdpartyLoginLbl) {
_thirdpartyLoginLbl = [[UILabel alloc] initWithFrame:CGRectMake(0, 20, KScreenWidth, 15)];
_thirdpartyLoginLbl.textAlignment = NSTextAlignmentCenter;
_thirdpartyLoginLbl.textColor = [UIColor orangeColor];
_thirdpartyLoginLbl.text = @"第三方平台";
_thirdpartyLoginLbl.font = [UIFont systemFontOfSize:15];
}
return _thirdpartyLoginLbl;
}
- (UIButton *)weChatBtn
{
if (!_weChatBtn) {
_weChatBtn = [UIButton buttonWithType:UIButtonTypeCustom];
_weChatBtn.backgroundColor = [UIColor orangeColor];
[_weChatBtn setFrame:CGRectMake(SpaceWidth, 70, 80, 40)];
_weChatBtn.layer.cornerRadius = 20;
_weChatBtn.layer.masksToBounds = YES;
[_weChatBtn setTitle:@"微信" forState:UIControlStateNormal];
[_weChatBtn addTarget:self action:@selector(thirdPartyBtnAction:) forControlEvents:UIControlEventTouchUpInside];
}
return _weChatBtn;
}
- (UIButton *)sinaBtn
{
if (!_sinaBtn) {
_sinaBtn = [UIButton buttonWithType:UIButtonTypeCustom];
_sinaBtn.backgroundColor = [UIColor orangeColor];
[_sinaBtn setFrame:CGRectMake(SpaceWidth*2+80, 70, 80, 40)];
_sinaBtn.layer.cornerRadius = 20;
_sinaBtn.layer.masksToBounds = YES;
[_sinaBtn setTitle:@"微博" forState:UIControlStateNormal];
[_sinaBtn addTarget:self action:@selector(thirdPartyBtnAction:) forControlEvents:UIControlEventTouchUpInside];
}
return _sinaBtn;
}
- (UIButton *)qqBtn
{
if (!_qqBtn) {
_qqBtn = [UIButton buttonWithType:UIButtonTypeCustom];
_qqBtn.backgroundColor = [UIColor orangeColor];
[_qqBtn setFrame:CGRectMake(SpaceWidth*3+80*2, 70, 80, 40)];
_qqBtn.layer.cornerRadius = 20;
_qqBtn.layer.masksToBounds = YES;
[_qqBtn setTitle:@"QQ" forState:UIControlStateNormal];
[_qqBtn addTarget:self action:@selector(thirdPartyBtnAction:) forControlEvents:UIControlEventTouchUpInside];
}
return _qqBtn;
}
- (UIButton *)cancelBtn
{
if (!_cancelBtn) {
_cancelBtn = [UIButton buttonWithType:UIButtonTypeCustom];
_cancelBtn.frame = CGRectMake(self.bounds.size.width-30, 10, 20, 20);
[_cancelBtn setBackgroundImage:[UIImage imageNamed:@"cancel"] forState:UIControlStateNormal];
[_cancelBtn addTarget:self action:@selector(cancelBtnAction) forControlEvents:UIControlEventTouchUpInside];
}
return _cancelBtn;
}
@end