修复了随机PK规则的弹框样式
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
//
|
||||
// XPAnchorRandomPKRuleView.h
|
||||
// xplan-ios
|
||||
//
|
||||
// Created by 冯硕 on 2022/12/23.
|
||||
//
|
||||
|
||||
#import <UIKit/UIKit.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
@interface XPAnchorRandomPKRuleView : UIView
|
||||
///
|
||||
@property (nonatomic,copy) NSString *ruleString;
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
@@ -0,0 +1,279 @@
|
||||
//
|
||||
// XPAnchorRandomPKRuleView.m
|
||||
// xplan-ios
|
||||
//
|
||||
// Created by 冯硕 on 2022/12/23.
|
||||
//
|
||||
|
||||
#import "XPAnchorRandomPKRuleView.h"
|
||||
///Third
|
||||
#import <Masonry/Masonry.h>
|
||||
///Tool
|
||||
#import "ThemeColor.h"
|
||||
#import "TTPopup.h"
|
||||
#import "UIImage+Utils.h"
|
||||
|
||||
@interface XPAnchorRandomPKRuleView ()
|
||||
///标题
|
||||
@property (nonatomic, strong) UILabel *titleLabel;
|
||||
///背景
|
||||
@property (nonatomic, strong) UIImageView *backgroundImageView;
|
||||
|
||||
///滚动
|
||||
@property (nonatomic,strong) UIScrollView *scrollView;
|
||||
///规则
|
||||
@property (nonatomic,strong) UILabel *ruleLabel;
|
||||
///随机标题
|
||||
@property (nonatomic,strong) UILabel *randomLabel;
|
||||
///随机背景
|
||||
@property (nonatomic,strong) UIImageView *randomImageView;
|
||||
///随机文案
|
||||
@property (nonatomic,strong) UILabel *randomContentLb;
|
||||
|
||||
///邀请标题
|
||||
@property (nonatomic,strong) UILabel *inviteLabel;
|
||||
///邀请背景
|
||||
@property (nonatomic,strong) UIImageView *inviteImageView;
|
||||
///邀请文案
|
||||
@property (nonatomic,strong) UILabel *inviteContentLb;
|
||||
///关闭
|
||||
@property (nonatomic, strong) UIButton *closeBtn;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation XPAnchorRandomPKRuleView
|
||||
|
||||
- (instancetype)initWithFrame:(CGRect)frame {
|
||||
if (self = [super initWithFrame:frame]) {
|
||||
[self initSubViews];
|
||||
[self initSubViewConstraints];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
#pragma mark - Private Method
|
||||
- (void)initSubViews {
|
||||
[self addSubview:self.backgroundImageView];
|
||||
[self addSubview:self.titleLabel];
|
||||
[self addSubview:self.closeBtn];
|
||||
[self.backgroundImageView addSubview:self.scrollView];
|
||||
|
||||
[self.scrollView addSubview:self.ruleLabel];
|
||||
|
||||
[self.scrollView addSubview:self.randomImageView];
|
||||
[self.scrollView addSubview:self.randomLabel];
|
||||
[self.scrollView addSubview:self.randomContentLb];
|
||||
|
||||
[self.scrollView addSubview:self.inviteImageView];
|
||||
[self.scrollView addSubview:self.inviteLabel];
|
||||
[self.scrollView addSubview:self.inviteContentLb];
|
||||
|
||||
|
||||
}
|
||||
|
||||
- (void)initSubViewConstraints {
|
||||
[self mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.width.mas_equalTo(300);
|
||||
make.height.mas_equalTo(324);
|
||||
make.bottom.mas_equalTo(self.backgroundImageView.mas_bottom);
|
||||
}];
|
||||
[self.backgroundImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.edges.mas_equalTo(0);
|
||||
}];
|
||||
[self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.centerX.mas_equalTo(self);
|
||||
make.top.mas_equalTo(self.backgroundImageView).mas_offset(82);
|
||||
make.height.mas_equalTo(21);
|
||||
}];
|
||||
|
||||
|
||||
[self.scrollView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(self.backgroundImageView).offset(120);
|
||||
make.left.right.mas_equalTo(self.backgroundImageView).inset(18);
|
||||
make.bottom.mas_equalTo(self.backgroundImageView).offset(-15);
|
||||
}];
|
||||
|
||||
[self.ruleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(self.scrollView);
|
||||
make.left.right.mas_equalTo(self.backgroundImageView).inset(18);
|
||||
}];
|
||||
|
||||
[self.randomLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(self.ruleLabel.mas_bottom).offset(16);
|
||||
make.centerX.mas_equalTo(self.scrollView);
|
||||
}];
|
||||
|
||||
[self.randomImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.size.mas_equalTo(CGSizeMake(88, 8));
|
||||
make.top.mas_equalTo(self.randomLabel.mas_bottom).offset(-6);
|
||||
make.centerX.mas_equalTo(self.randomLabel);
|
||||
}];
|
||||
|
||||
[self.randomContentLb mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.right.mas_equalTo(self.backgroundImageView).inset(18);
|
||||
make.top.mas_equalTo(self.randomImageView.mas_bottom).offset(8);
|
||||
}];
|
||||
|
||||
[self.inviteLabel mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.top.mas_equalTo(self.randomContentLb.mas_bottom).offset(16);
|
||||
make.centerX.mas_equalTo(self.scrollView);
|
||||
}];
|
||||
|
||||
[self.inviteImageView mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.size.mas_equalTo(CGSizeMake(88, 8));
|
||||
make.top.mas_equalTo(self.inviteLabel.mas_bottom).offset(-6);
|
||||
make.centerX.mas_equalTo(self.inviteLabel);
|
||||
}];
|
||||
|
||||
[self.inviteContentLb mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.left.right.mas_equalTo(self.backgroundImageView).inset(18);
|
||||
make.top.mas_equalTo(self.inviteImageView.mas_bottom).offset(8);
|
||||
}];
|
||||
|
||||
[self.closeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
|
||||
make.right.top.mas_equalTo(self.backgroundImageView);
|
||||
make.width.height.mas_equalTo(32);
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark - Event Response
|
||||
- (void)onCloseBtnClick:(UIButton *)button {
|
||||
[TTPopup dismiss];
|
||||
}
|
||||
|
||||
- (void)setRuleString:(NSString *)ruleString {
|
||||
if ([ruleString containsString:@"\\n"]) {
|
||||
ruleString = [ruleString stringByReplacingOccurrencesOfString:@"\\n" withString:@"\n"];
|
||||
}
|
||||
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
|
||||
paragraphStyle.lineSpacing = 5;
|
||||
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] initWithString:ruleString attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:12], NSForegroundColorAttributeName:[ThemeColor mainTextColor]}];
|
||||
[attribute addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, ruleString.length)];
|
||||
self.ruleLabel.attributedText = attribute;
|
||||
CGSize size = [self.ruleLabel sizeThatFits:CGSizeMake(300 -36, CGFLOAT_MAX)];
|
||||
self.scrollView.contentSize = CGSizeMake(0, size.height + 70 * 2 + 20);
|
||||
}
|
||||
|
||||
#pragma mark - Getters And Setters
|
||||
- (UIImageView *)backgroundImageView {
|
||||
if (!_backgroundImageView) {
|
||||
_backgroundImageView = [[UIImageView alloc] init];
|
||||
_backgroundImageView.userInteractionEnabled = YES;
|
||||
_backgroundImageView.image = [UIImage imageNamed:@"anchorPK_invite_bg"];
|
||||
}
|
||||
return _backgroundImageView;
|
||||
}
|
||||
|
||||
- (UILabel *)titleLabel {
|
||||
if (!_titleLabel) {
|
||||
_titleLabel = [[UILabel alloc] init];
|
||||
_titleLabel.text = @"PK规则";
|
||||
_titleLabel.textColor = [UIColor whiteColor];
|
||||
_titleLabel.font = [UIFont systemFontOfSize:15];
|
||||
}
|
||||
return _titleLabel;
|
||||
}
|
||||
|
||||
|
||||
- (UIImageView *)randomImageView {
|
||||
if (!_randomImageView) {
|
||||
_randomImageView = [[UIImageView alloc] init];
|
||||
_randomImageView.userInteractionEnabled = YES;
|
||||
_randomImageView.image = [UIImage gradientColorImageFromColors:@[[ThemeColor colorWithHexString:@"#1CD7FD"], [ThemeColor colorWithHexString:@"#9277FF"], [ThemeColor colorWithHexString:@"FF6BA3"]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)];
|
||||
_randomImageView.contentMode = UIViewContentModeScaleAspectFill;
|
||||
_randomImageView.layer.masksToBounds = YES;
|
||||
_randomImageView.layer.cornerRadius = 4;
|
||||
}
|
||||
return _randomImageView;
|
||||
}
|
||||
|
||||
- (UILabel *)randomLabel {
|
||||
if (!_randomLabel) {
|
||||
_randomLabel = [[UILabel alloc] init];
|
||||
_randomLabel.font = [UIFont systemFontOfSize:12 weight:UIFontWeightMedium];
|
||||
_randomLabel.textColor = [ThemeColor mainTextColor];
|
||||
_randomLabel.text= @"随机PK";
|
||||
}
|
||||
return _randomLabel;
|
||||
}
|
||||
|
||||
- (UILabel *)ruleLabel {
|
||||
if (!_ruleLabel) {
|
||||
_ruleLabel = [[UILabel alloc] init];
|
||||
_ruleLabel.font = [UIFont systemFontOfSize:12];
|
||||
_ruleLabel.textColor = [ThemeColor mainTextColor];
|
||||
_ruleLabel.numberOfLines = 0;
|
||||
}
|
||||
return _ruleLabel;
|
||||
}
|
||||
|
||||
- (UIScrollView *)scrollView {
|
||||
if (!_scrollView) {
|
||||
_scrollView = [[UIScrollView alloc] init];
|
||||
_scrollView.backgroundColor = [UIColor clearColor];
|
||||
_scrollView.showsHorizontalScrollIndicator = NO;
|
||||
}
|
||||
return _scrollView;
|
||||
}
|
||||
|
||||
|
||||
- (UILabel *)randomContentLb {
|
||||
if (!_randomContentLb) {
|
||||
_randomContentLb = [[UILabel alloc] init];
|
||||
NSString * title = @"参与匹配,随机与一名主播房主播PK,匹配成功后开启PK。PK时长固定";
|
||||
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] initWithString:title attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:12], NSForegroundColorAttributeName:[ThemeColor mainTextColor]}];
|
||||
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
|
||||
paragraphStyle.lineSpacing = 5;
|
||||
[attribute addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, title.length)];
|
||||
_randomContentLb.attributedText = attribute;
|
||||
_randomContentLb.numberOfLines = 0;
|
||||
}
|
||||
return _randomContentLb;
|
||||
}
|
||||
|
||||
- (UIImageView *)inviteImageView {
|
||||
if (!_inviteImageView) {
|
||||
_inviteImageView = [[UIImageView alloc] init];
|
||||
_inviteImageView.userInteractionEnabled = YES;
|
||||
_inviteImageView.image = [UIImage gradientColorImageFromColors:@[[ThemeColor colorWithHexString:@"#1CD7FD"], [ThemeColor colorWithHexString:@"#9277FF"], [ThemeColor colorWithHexString:@"FF6BA3"]] gradientType:GradientTypeLeftToRight imgSize:CGSizeMake(10, 10)];
|
||||
_inviteImageView.contentMode = UIViewContentModeScaleAspectFill;
|
||||
_inviteImageView.layer.masksToBounds = YES;
|
||||
_inviteImageView.layer.cornerRadius = 4;
|
||||
}
|
||||
return _inviteImageView;
|
||||
}
|
||||
|
||||
- (UILabel *)inviteLabel {
|
||||
if (!_inviteLabel) {
|
||||
_inviteLabel = [[UILabel alloc] init];
|
||||
_inviteLabel.font = [UIFont systemFontOfSize:12 weight:UIFontWeightMedium];
|
||||
_inviteLabel.textColor = [ThemeColor mainTextColor];
|
||||
_inviteLabel.text= @"邀请PK";
|
||||
}
|
||||
return _inviteLabel;
|
||||
}
|
||||
|
||||
- (UILabel *)inviteContentLb {
|
||||
if (!_inviteContentLb) {
|
||||
_inviteContentLb = [[UILabel alloc] init];
|
||||
NSString * title = @"指定一个主播房主播,邀请其进行PK,对方接受后开启PK";
|
||||
NSMutableAttributedString * attribute = [[NSMutableAttributedString alloc] initWithString:title attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:12], NSForegroundColorAttributeName:[ThemeColor mainTextColor]}];
|
||||
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init];
|
||||
paragraphStyle.lineSpacing = 5;
|
||||
[attribute addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, title.length)];
|
||||
_inviteContentLb.attributedText = attribute;
|
||||
_inviteContentLb.numberOfLines = 0;
|
||||
}
|
||||
return _inviteContentLb;
|
||||
}
|
||||
|
||||
- (UIButton *)closeBtn {
|
||||
if (!_closeBtn) {
|
||||
_closeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
|
||||
[_closeBtn addTarget:self action:@selector(onCloseBtnClick:) forControlEvents:UIControlEventTouchUpInside];
|
||||
[_closeBtn setBackgroundImage:[UIImage imageNamed:@"anchorPk_result_close"] forState:UIControlStateNormal];
|
||||
}
|
||||
return _closeBtn;
|
||||
}
|
||||
@end
|
@@ -15,6 +15,7 @@
|
||||
#import "StatisticsServiceHelper.h"
|
||||
#import "XCCurrentVCStackManager.h"
|
||||
#import "Api+Room.h"
|
||||
#import "XPAnchorRandomPKRuleView.h"
|
||||
///P
|
||||
#import "XPAnchorPKPresenter.h"
|
||||
#import "XPAnchorPKProtocol.h"
|
||||
@@ -106,7 +107,7 @@
|
||||
|
||||
[Api requestAnchorPkRule:^(BaseModel * _Nullable data, NSInteger code, NSString * _Nullable msg) {
|
||||
if (code == 200) {
|
||||
XPAnchorPKRuleView *view = [[XPAnchorPKRuleView alloc] init];
|
||||
XPAnchorRandomPKRuleView *view = [[XPAnchorRandomPKRuleView alloc] init];
|
||||
view.ruleString = data.data;
|
||||
[TTPopup popupView:view style:TTPopupStyleAlert];
|
||||
}
|
||||
|
Reference in New Issue
Block a user