提交
This commit is contained in:
87
QXLive/Tabbar/TabbarCustomView/CustomVersionUpdateView.m
Executable file
87
QXLive/Tabbar/TabbarCustomView/CustomVersionUpdateView.m
Executable file
@@ -0,0 +1,87 @@
|
||||
//
|
||||
// CustomVersionUpdateView.m
|
||||
// SoundRiver
|
||||
//
|
||||
// Created by y1758946235 on 2020/2/17.
|
||||
//
|
||||
|
||||
#import "CustomVersionUpdateView.h"
|
||||
@interface CustomVersionUpdateView ()
|
||||
@property (nonatomic, strong) UIButton *centerBgBtn;
|
||||
@property (nonatomic, copy) NSString *downloadUrl;
|
||||
@end
|
||||
@implementation CustomVersionUpdateView
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame {
|
||||
self = [super initWithFrame:frame];
|
||||
if (self) {
|
||||
self.backgroundColor = RGBA(0, 0, 0, 0.5);
|
||||
[self centerBgBtn];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)tapClick {
|
||||
[self removeFromSuperview];
|
||||
}
|
||||
|
||||
- (void)getDownloadUrl:(NSString *)downloadUrl isForceUpdate:(NSString *)ForceUpdate {
|
||||
self.downloadUrl = downloadUrl;
|
||||
if ([ForceUpdate intValue] != 1) {
|
||||
self.userInteractionEnabled = YES;
|
||||
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapClick)];
|
||||
[self addGestureRecognizer:tap];
|
||||
}
|
||||
}
|
||||
|
||||
#pragma mark - Getter
|
||||
|
||||
- (NSString *)downloadUrl
|
||||
{
|
||||
if (!_downloadUrl) {
|
||||
_downloadUrl = [[NSString alloc] init];
|
||||
}
|
||||
return _downloadUrl;
|
||||
}
|
||||
|
||||
- (UIButton *)centerBgBtn
|
||||
{
|
||||
if (!_centerBgBtn) {
|
||||
_centerBgBtn = [[UIButton alloc] initWithFrame:CGRectZero];
|
||||
[_centerBgBtn setBackgroundImage:[UIImage imageNamed:@"sr_update_version"] forState:UIControlStateNormal];
|
||||
[_centerBgBtn setBackgroundImage:[UIImage imageNamed:@"sr_update_version"] forState:UIControlStateHighlighted];
|
||||
[_centerBgBtn addTarget:self action:@selector(updateClick) forControlEvents:UIControlEventTouchUpInside];
|
||||
// UIView *view = [QuickCreatUI creatUIViewWithSuperView:_centerBgBtn andFrame:CGRectZero color:UIColor.redColor];
|
||||
[self addSubview:_centerBgBtn];
|
||||
[_centerBgBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerX.mas_equalTo(0);
|
||||
make.centerY.mas_equalTo(0);
|
||||
make.size.mas_equalTo(CGSizeMake(ScaleWidth(305), ScaleWidth(345)));
|
||||
}];
|
||||
// [view mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
// make.centerX.mas_equalTo(0);
|
||||
// make.centerY.mas_equalTo(0);
|
||||
// make.size.mas_equalTo(CGSizeMake(AUTO_CEIL_WIETH(305), AUTO_CEIL_WIETH(40)));
|
||||
// }];
|
||||
}
|
||||
return _centerBgBtn;
|
||||
}
|
||||
|
||||
- (void)updateClick {
|
||||
if (@available(iOS 10.0, *)) {
|
||||
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:self.downloadUrl] options:@{} completionHandler:nil];
|
||||
} else {
|
||||
// Fallback on earlier versions
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
// Only override drawRect: if you perform custom drawing.
|
||||
// An empty implementation adversely affects performance during animation.
|
||||
- (void)drawRect:(CGRect)rect {
|
||||
// Drawing code
|
||||
}
|
||||
*/
|
||||
|
||||
@end
|
||||
Reference in New Issue
Block a user