修复了随机PK规则的弹框样式

This commit is contained in:
fengshuo
2022-12-23 15:49:28 +08:00
parent 33bfbbb88d
commit f1ae4a4a39
4 changed files with 304 additions and 1 deletions

View File

@@ -1133,6 +1133,7 @@
E8DBB6F927B639A300AA285D /* LittleGameStageView.m in Sources */ = {isa = PBXBuildFile; fileRef = E8DBB6F827B639A300AA285D /* LittleGameStageView.m */; };
E8DBB6FD27B63CE000AA285D /* LittleGameMicroView.m in Sources */ = {isa = PBXBuildFile; fileRef = E8DBB6FC27B63CE000AA285D /* LittleGameMicroView.m */; };
E8DBB70127B6501200AA285D /* XPLittleGameMiniStageView.m in Sources */ = {isa = PBXBuildFile; fileRef = E8DBB70027B6501200AA285D /* XPLittleGameMiniStageView.m */; };
E8DD25DA295583920043C7D5 /* XPAnchorRandomPKRuleView.m in Sources */ = {isa = PBXBuildFile; fileRef = E8DD25D9295583920043C7D5 /* XPAnchorRandomPKRuleView.m */; };
E8DEC98B27637EA50078CB70 /* candyTree_open.svga in Resources */ = {isa = PBXBuildFile; fileRef = E8DEC98927637EA50078CB70 /* candyTree_open.svga */; };
E8DEC98C27637EA50078CB70 /* candyTree_transform.svga in Resources */ = {isa = PBXBuildFile; fileRef = E8DEC98A27637EA50078CB70 /* candyTree_transform.svga */; };
E8DEC992276441AA0078CB70 /* XPCandyTreeAnimationModel.m in Sources */ = {isa = PBXBuildFile; fileRef = E8DEC991276441AA0078CB70 /* XPCandyTreeAnimationModel.m */; };
@@ -3353,6 +3354,8 @@
E8DBB6FC27B63CE000AA285D /* LittleGameMicroView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = LittleGameMicroView.m; sourceTree = "<group>"; };
E8DBB6FF27B6501200AA285D /* XPLittleGameMiniStageView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPLittleGameMiniStageView.h; sourceTree = "<group>"; };
E8DBB70027B6501200AA285D /* XPLittleGameMiniStageView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPLittleGameMiniStageView.m; sourceTree = "<group>"; };
E8DD25D8295583920043C7D5 /* XPAnchorRandomPKRuleView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPAnchorRandomPKRuleView.h; sourceTree = "<group>"; };
E8DD25D9295583920043C7D5 /* XPAnchorRandomPKRuleView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = XPAnchorRandomPKRuleView.m; sourceTree = "<group>"; };
E8DEC98927637EA50078CB70 /* candyTree_open.svga */ = {isa = PBXFileReference; lastKnownFileType = file; path = candyTree_open.svga; sourceTree = "<group>"; };
E8DEC98A27637EA50078CB70 /* candyTree_transform.svga */ = {isa = PBXFileReference; lastKnownFileType = file; path = candyTree_transform.svga; sourceTree = "<group>"; };
E8DEC990276441AA0078CB70 /* XPCandyTreeAnimationModel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XPCandyTreeAnimationModel.h; sourceTree = "<group>"; };
@@ -4374,6 +4377,8 @@
children = (
9B1B72BD2800422E003FACE9 /* XPAnchorPKRuleView.h */,
9B1B72BE2800422E003FACE9 /* XPAnchorPKRuleView.m */,
E8DD25D8295583920043C7D5 /* XPAnchorRandomPKRuleView.h */,
E8DD25D9295583920043C7D5 /* XPAnchorRandomPKRuleView.m */,
9B2EA7C428041EFC00ED17BF /* XPAnchorPkPanelView.h */,
9B2EA7C528041EFC00ED17BF /* XPAnchorPkPanelView.m */,
9B2EA7CA2804245500ED17BF /* XPAnchorPKPanelUserView.h */,
@@ -9872,6 +9877,7 @@
18E7B31E26F0984C0064BC9B /* UserLevelVo.m in Sources */,
E8DBB70127B6501200AA285D /* XPLittleGameMiniStageView.m in Sources */,
E851E46227FF1314002F3ACB /* XPMineGuildEmptyTableViewCell.m in Sources */,
E8DD25DA295583920043C7D5 /* XPAnchorRandomPKRuleView.m in Sources */,
E8834E3B280012B60029CCC1 /* XPMineGuildRemoveMemberViewController.m in Sources */,
9B734F79288A9C4B00CBDAA9 /* XPMineGameTableViewCell.m in Sources */,
E8664EDC27E43632000171BA /* XPRoomPKEmptyTableViewCell.m in Sources */,

View File

@@ -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

View File

@@ -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

View File

@@ -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];
}