ThirdPartyView.m
4.63 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
124
125
126
127
128
129
130
131
132
//
// 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 whiteColor];
[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 blackColor];
_thirdpartyLoginLbl.text = @"第三方平台";
_thirdpartyLoginLbl.font = [UIFont systemFontOfSize:15];
}
return _thirdpartyLoginLbl;
}
- (UIButton *)weChatBtn
{
if (!_weChatBtn) {
_weChatBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[_weChatBtn setFrame:CGRectMake(SpaceWidth, 70, 80, 40)];
[_weChatBtn setTitle:@"微信" forState:UIControlStateNormal];
[_weChatBtn addTarget:self action:@selector(thirdPartyBtnAction:) forControlEvents:UIControlEventTouchUpInside];
_weChatBtn.titleLabel.font = [UIFont systemFontOfSize:18];
[_weChatBtn setTitleColor:[UIColor colorWithRed:23/255.0 green:110/255.0 blue:254/255.0 alpha:1] forState:UIControlStateNormal];
_weChatBtn.layer.cornerRadius = 20;
_weChatBtn.layer.masksToBounds = YES;
_weChatBtn.layer.borderColor = [UIColor blackColor].CGColor;
_weChatBtn.layer.borderWidth = 1;
}
return _weChatBtn;
}
- (UIButton *)sinaBtn
{
if (!_sinaBtn) {
_sinaBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[_sinaBtn setFrame:CGRectMake(SpaceWidth*2+80, 70, 80, 40)];
[_sinaBtn setTitle:@"微博" forState:UIControlStateNormal];
[_sinaBtn addTarget:self action:@selector(thirdPartyBtnAction:) forControlEvents:UIControlEventTouchUpInside];
_sinaBtn.titleLabel.font = [UIFont systemFontOfSize:18];
[_sinaBtn setTitleColor:[UIColor colorWithRed:23/255.0 green:110/255.0 blue:254/255.0 alpha:1] forState:UIControlStateNormal];
_sinaBtn.layer.cornerRadius = 20;
_sinaBtn.layer.masksToBounds = YES;
_sinaBtn.layer.borderColor = [UIColor blackColor].CGColor;
_sinaBtn.layer.borderWidth = 1;
}
return _sinaBtn;
}
- (UIButton *)qqBtn
{
if (!_qqBtn) {
_qqBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[_qqBtn setFrame:CGRectMake(SpaceWidth*3+80*2, 70, 80, 40)];
[_qqBtn setTitle:@"QQ" forState:UIControlStateNormal];
[_qqBtn addTarget:self action:@selector(thirdPartyBtnAction:) forControlEvents:UIControlEventTouchUpInside];
_qqBtn.titleLabel.font = [UIFont systemFontOfSize:18];
[_qqBtn setTitleColor:[UIColor colorWithRed:23/255.0 green:110/255.0 blue:254/255.0 alpha:1] forState:UIControlStateNormal];
_qqBtn.layer.cornerRadius = 20;
_qqBtn.layer.masksToBounds = YES;
_qqBtn.layer.borderColor = [UIColor blackColor].CGColor;
_qqBtn.layer.borderWidth = 1;
}
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