123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565 |
- //
- // YMInvitingPrizesSharePosterPopupView.m
- // MSYOUPAI
- //
- // Created by YoMi on 2024/3/15.
- // Copyright © 2024 MS. All rights reserved.
- //
- #import "YMInvitingPrizesSharePosterPopupView.h"
- #import "YMInvitingPrizesViewModel.h"
- @interface YMInvitingPrizesSharePosterPopupView ()<TYCyclePagerViewDataSource,TYCyclePagerViewDelegate>
- /// 邀请有奖VM
- @property (nonatomic, strong) YMInvitingPrizesViewModel *viewModel;
- /// 海报图
- @property (nonatomic, strong) TYCyclePagerView *posterView;
- /// 按钮视图
- @property (nonatomic, strong) UIView *buttonView;
- /// 复制链接按钮
- @property (nonatomic, strong) UIButton *copyLinkBtn;
- /// 切换模式按钮
- @property (nonatomic, strong) UIButton *switchModeBtn;
- /// 保存二维码按钮
- @property (nonatomic, strong) UIButton *saveQRCodeBtn;
- /// 是否反方向
- @property (nonatomic, assign) BOOL isReverseDirectionScroll;
- @end
- @implementation YMInvitingPrizesSharePosterPopupView
- - (void)ym_setupViews{
- self.frame = CGRectMake(0, 0, kFrameWidth, kFrameHeight - kYMNavHeight);
-
- [self addSubview:self.posterView];
- [self addSubview:self.buttonView];
- [self.buttonView addSubview:self.copyLinkBtn];
- [self.buttonView addSubview:self.switchModeBtn];
- [self.buttonView addSubview:self.saveQRCodeBtn];
-
- [self setNeedsUpdateConstraints];
- [self updateConstraintsIfNeeded];
- }
- - (void)updateConstraints{
- [self.posterView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self);
- make.left.equalTo(self);
- make.right.equalTo(self);
- }];
-
- [self.buttonView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.posterView.mas_bottom).offset(adapt(40));
- make.left.equalTo(self);
- make.right.equalTo(self);
- make.bottom.equalTo(self);
- }];
-
- [self.copyLinkBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerY.equalTo(self.switchModeBtn.mas_centerY);
- make.right.equalTo(self.switchModeBtn.mas_left).offset(adapt(-15));
- make.size.mas_equalTo(CGSizeMake(adapt(120), adapt(120)));
- }];
-
- [self.switchModeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerX.equalTo(self.buttonView.mas_centerX);
- make.top.equalTo(self.buttonView).offset(adapt(20));
- make.bottom.equalTo(self.buttonView).offset(adapt(-20));
- make.size.mas_equalTo(CGSizeMake(adapt(120), adapt(120)));
- }];
-
- [self.saveQRCodeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerY.equalTo(self.switchModeBtn.mas_centerY);
- make.left.equalTo(self.switchModeBtn.mas_right).offset(adapt(15));
- make.size.mas_equalTo(CGSizeMake(adapt(120), adapt(120)));
- }];
-
- // NSArray *btnArr = @[self.copyLinkBtn,self.switchModeBtn,self.saveQRCodeBtn];
- //
- // // 实现masonry水平固定控件宽度方法
- // // axisType 横排还是竖排
- // // fixedSpacing 两个控件间隔
- // // leadSpacing 第一个控件与边缘的间隔
- // // tailSpacing 最后一个控件与边缘的间隔
- // [btnArr mas_distributeViewsAlongAxis:MASAxisTypeHorizontal withFixedSpacing:adapt(15) leadSpacing:adapt(10) tailSpacing:adapt(10)];
- //
- // // 设置array的垂直方向的约束
- // [btnArr mas_makeConstraints:^(MASConstraintMaker *make) {
- // make.top.equalTo(self.buttonView).offset(adapt(20));
- // make.bottom.equalTo(self.buttonView).offset(adapt(-20));
- // make.height.mas_equalTo(adapt(120));
- // }];
-
- [super updateConstraints];
- }
- - (void)ym_bindViewModel:(YMInvitingPrizesViewModel *)viewModel{
- if (!viewModel) {
- return;
- }
-
- _viewModel = viewModel;
-
- @weakify(self);
- [[self.viewModel.refreshUISubject takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id result) {
- @strongify(self)
- [self.posterView reloadData];
- }];
-
- }
- #pragma mark - TYCyclePagerViewDataSource
- - (NSInteger)numberOfItemsInPagerView:(TYCyclePagerView *)pageView {
- return self.viewModel.posterDataArray.count;
- }
- - (UICollectionViewCell *)pagerView:(TYCyclePagerView *)pagerView cellForItemAtIndex:(NSInteger)index {
- YMInvitingPrizesSharePosterCell *cell = [pagerView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([YMInvitingPrizesSharePosterCell class]) forIndex:index];
- [cell ym_bindViewModel:self.viewModel.posterDataArray[index]];
- return cell;
- }
- /** banner样式*/
- - (TYCyclePagerViewLayout *)layoutForPagerView:(TYCyclePagerView *)pageView {
- TYCyclePagerViewLayout *layout = [[TYCyclePagerViewLayout alloc]init];
- layout.itemSize = CGSizeMake(adapt(285), adapt(393));
- layout.itemSpacing = adapt(50);
- layout.itemHorizontalCenter = YES;
- layout.scrollDirection = TYCyclePagerScrollDirectionHorizontal;
- return layout;
- }
- #pragma mark - TYCyclePagerViewDelegate
- /** pagerView当前展示*/
- - (void)pagerView:(TYCyclePagerView *)pageView didScrollFromIndex:(NSInteger)fromIndex toIndex:(NSInteger)toIndex {
-
- if (toIndex == 0) {
- self.isReverseDirectionScroll = NO;
- }
-
- if (toIndex+1 == self.viewModel.posterDataArray.count) {
- self.isReverseDirectionScroll = YES;
- }
-
- }
- - (void)pagerView:(TYCyclePagerView *)pageView didSelectedItemCell:(__kindof UICollectionViewCell *)cell atIndex:(NSInteger)index{
- }
- - (void)pagerViewDidScroll:(TYCyclePagerView *)pageView{
- }
- /** pagerView将开始拖动*/
- - (void)pagerViewWillBeginDragging:(TYCyclePagerView *)pageView{
- }
- /** pagerView将开始减速*/
- - (void)pagerViewWillBeginDecelerating:(TYCyclePagerView *)pageView{
- }
- /** pagerView确认结束*/
- - (void)pagerViewDidEndDragging:(TYCyclePagerView *)pageView willDecelerate:(BOOL)decelerate{
- }
- /** pagerView确认减速*/
- - (void)pagerViewDidEndDecelerating:(TYCyclePagerView *)pageView{
- }
- /** pagerView将开始滚动动画*/
- - (void)pagerViewWillBeginScrollingAnimation:(TYCyclePagerView *)pageView{
- }
- /** pagerView确认结束滚动动画*/
- - (void)pagerViewDidEndScrollingAnimation:(TYCyclePagerView *)pageView{
- }
- - (void)switchModeScrollToItem{
- NSInteger currentIndex = self.posterView.curIndex;
- if (self.isReverseDirectionScroll) {
- currentIndex--;
- [self.posterView scrollToItemAtIndex:currentIndex animate:YES];
- } else {
- currentIndex++;
- [self.posterView scrollToItemAtIndex:currentIndex animate:YES];
- }
- }
- #pragma mark - 保存到相册
- - (void)image:(UIImage *)image didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo {
- if(error) {
- [ZCHUDHelper showTitle:@"保存图片失败"];
- }else {
- [ZCHUDHelper showTitle:@"保存图片成功"];
- }
- }
- - (UIImage *)getCurrentImage {
- UIImage *image = nil;
- YMInvitingPrizesSharePosterCell *cell = (YMInvitingPrizesSharePosterCell *)[self.posterView curIndexCell];
- if (cell.finishedLoad) {
- image = [cell cutImage:cell.baseView];
- } else {
- [ZCHUDHelper showTitle:@"请等待图片加载完成"];
- }
- return image;
- }
- - (TYCyclePagerView *)posterView{
- if (!_posterView) {
- _posterView = [[TYCyclePagerView alloc]init];
- _posterView.dataSource = self;
- _posterView.delegate = self;
- //无限滚动
- _posterView.isInfiniteLoop = NO;
- //自动轮播
- _posterView.autoScrollInterval = 0;
- [_posterView registerClass:[YMInvitingPrizesSharePosterCell class] forCellWithReuseIdentifier:NSStringFromClass([YMInvitingPrizesSharePosterCell class])];
- _posterView.userInteractionEnabled = YES;
- WS(weakSelf)
- UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] init];
- [_posterView addGestureRecognizer:tap];
- [[[tap rac_gestureSignal] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) {
- if (weakSelf.dismissBlock) {
- weakSelf.dismissBlock();
- }
- }];
- }
- return _posterView;
- }
- - (UIView *)buttonView{
- if (!_buttonView) {
- _buttonView = [[UIView alloc]init];
- _buttonView.backgroundColor = HexColorFromRGB(0xFFFFFF);
- [_buttonView addRectCorner:UIRectCornerTopLeft|UIRectCornerTopRight radius:adapt(10)];
- _buttonView.userInteractionEnabled = YES;
- WS(weakSelf)
- UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] init];
- [_buttonView addGestureRecognizer:tap];
- [[[tap rac_gestureSignal] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) {
- if (weakSelf.dismissBlock) {
- weakSelf.dismissBlock();
- }
- }];
- }
- return _buttonView;
- }
- - (UIButton *)copyLinkBtn {
- if(!_copyLinkBtn){
- _copyLinkBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- _copyLinkBtn.frame = CGRectMake(0,0,adapt(120),adapt(120));
- _copyLinkBtn.titleLabel.font = LCFont(12);
- [_copyLinkBtn setTitleColor:HexColorFromRGB(0x333333) forState:UIControlStateNormal];
- [_copyLinkBtn ym_imageLocationStyle:YMImageLocationStyleTop spacing:adapt(5) imageLocationBlock:^(UIButton * _Nonnull button) {
- [button setTitle:@"复制链接" forState:UIControlStateNormal];
- [button setImage:ImageByName(@"ym_inviting_prizes_share_poster_copy_link_icon") forState:UIControlStateNormal];
- }];
- WS(weakSelf)
- [[[_copyLinkBtn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) {
- UIPasteboard *pab = [UIPasteboard generalPasteboard];
- pab.string = weakSelf.viewModel.posterDataArray[0].qrCodeContent;
- if (pab == nil) {
- [ZCHUDHelper showTitle:@"复制失败"];
- }else{
- [ZCHUDHelper showTitle:@"已复制"];
- }
- }];
- }
- return _copyLinkBtn;
- }
- - (UIButton *)switchModeBtn {
- if(!_switchModeBtn){
- _switchModeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- _switchModeBtn.frame = CGRectMake(0,0,adapt(120),adapt(120));
- _switchModeBtn.titleLabel.font = LCFont(12);
- [_switchModeBtn setTitleColor:HexColorFromRGB(0x333333) forState:UIControlStateNormal];
- [_switchModeBtn ym_imageLocationStyle:YMImageLocationStyleTop spacing:adapt(5) imageLocationBlock:^(UIButton * _Nonnull button) {
- [button setTitle:@"切换模式" forState:UIControlStateNormal];
- [button setImage:ImageByName(@"ym_inviting_prizes_share_poster_switch_mode_icon") forState:UIControlStateNormal];
- }];
- WS(weakSelf)
- [[[_switchModeBtn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) {
- [weakSelf switchModeScrollToItem];
- }];
- }
- return _switchModeBtn;
- }
- - (UIButton *)saveQRCodeBtn {
- if(!_saveQRCodeBtn){
- _saveQRCodeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
- _saveQRCodeBtn.frame = CGRectMake(0,0,adapt(120),adapt(120));
- _saveQRCodeBtn.titleLabel.font = LCFont(12);
- [_saveQRCodeBtn setTitleColor:HexColorFromRGB(0x333333) forState:UIControlStateNormal];
- [_saveQRCodeBtn ym_imageLocationStyle:YMImageLocationStyleTop spacing:adapt(5) imageLocationBlock:^(UIButton * _Nonnull button) {
- [button setTitle:@"保存二维码" forState:UIControlStateNormal];
- [button setImage:ImageByName(@"ym_inviting_prizes_share_poster_save_qr_code_icon") forState:UIControlStateNormal];
- }];
- WS(weakSelf)
- [[[_saveQRCodeBtn rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:self.rac_willDeallocSignal] subscribeNext:^(id x) {
- UIImage *poster = [weakSelf getCurrentImage];
- if (poster == nil) {
- return;
- }
- NSData *imageData = UIImagePNGRepresentation(poster);
- UIImage *image = [UIImage imageWithData:imageData];
- UIImageWriteToSavedPhotosAlbum(image, self, @selector(image:didFinishSavingWithError:contextInfo:), nil);
- }];
- }
- return _saveQRCodeBtn;
- }
- @end
- @interface YMInvitingPrizesSharePosterCell()
- /** 海报lVM*/
- @property (nonatomic, strong) YMInvitingPrizesSharePosterCellViewModel *viewModel;
- /** 完成加载*/
- @property (nonatomic, assign, readwrite) BOOL finishedLoad;
- /** 海报图片*/
- @property (nonatomic, strong) UIImageView *posterImage;
- /** 用户头像图片*/
- @property (nonatomic, strong) UIImageView *userAvatarImage;
- /** 用户昵称标签*/
- @property (nonatomic, strong) UILabel *userNicknameLb;
- /** 用户代码标签*/
- @property (nonatomic, strong) UILabel *userCodeLb;
- /** 二维码图片*/
- @property (nonatomic, strong) UIImageView *qrCodeImage;
- @end
- @implementation YMInvitingPrizesSharePosterCell
- - (void)ym_setupViews{
- [self.contentView addSubview:self.baseView];
- [self.baseView addSubview:self.posterImage];
- [self.baseView addSubview:self.userAvatarImage];
- [self.baseView addSubview:self.userNicknameLb];
- [self.baseView addSubview:self.userCodeLb];
- [self.baseView addSubview:self.qrCodeImage];
- [self setNeedsUpdateConstraints];
- [self updateConstraintsIfNeeded];
- }
- - (void)updateConstraints {
- [self.baseView mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.contentView);
- make.left.equalTo(self.contentView);
- make.right.equalTo(self.contentView);
- make.bottom.equalTo(self.contentView);
- }];
-
- [self.posterImage mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.baseView);
- make.left.equalTo(self.baseView);
- make.right.equalTo(self.baseView);
- }];
- [self.userAvatarImage mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.posterImage.mas_bottom).offset(adapt(30));
- make.left.equalTo(self.baseView).offset(adapt(30));
- make.width.height.mas_equalTo(adapt(60));
- make.bottom.equalTo(self.baseView).offset(adapt(-30));
- }];
- [self.userNicknameLb mas_makeConstraints:^(MASConstraintMaker *make) {
- make.bottom.equalTo(self.userAvatarImage.mas_centerY).offset(adapt(-5));
- make.left.equalTo(self.userAvatarImage.mas_right).offset(adapt(10));
- }];
-
- [self.userCodeLb mas_makeConstraints:^(MASConstraintMaker *make) {
- make.top.equalTo(self.userAvatarImage.mas_centerY).offset(adapt(5));
- make.left.equalTo(self.userAvatarImage.mas_right).offset(adapt(10));
- }];
-
- [self.qrCodeImage mas_makeConstraints:^(MASConstraintMaker *make) {
- make.centerY.equalTo(self.userAvatarImage).offset(adapt(0));
- make.right.equalTo(self.baseView).offset(adapt(-20));
- make.width.height.mas_equalTo(adapt(46));
- }];
- [super updateConstraints];
- }
- - (void)ym_bindViewModel:(YMInvitingPrizesSharePosterCellViewModel*)viewModel{
- if (!viewModel) {
- return;
- }
- _viewModel = viewModel;
-
- // [self.posterImage sd_setImageWithURL:[LCTools getImageUrlWithAddress:@""] placeholderImage:nil options:SDWebImageRetryFailed | SDWebImageHighPriority | SDWebImageProgressiveDownload | SDWebImageAvoidAutoSetImage | SDWebImageScaleDownLargeImages completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
- // self.finishedLoad = image ? YES : NO;
- // if (image && cacheType == SDImageCacheTypeNone) {
- // CATransition *transition = [CATransition animation];
- // transition.type = kCATransitionFade;
- // transition.duration = 0.3;
- // transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
- // [self.posterImage.layer addAnimation:transition forKey:nil];
- // }
- // }];
- self.finishedLoad = YES;
-
- self.posterImage.image = ImageByName(self.viewModel.posterUrl);
-
- //[self.userAvatarImage sd_setImageWithURL:[LCTools getImageUrlWithAddress:[LCSaveModel getUserModel].youpaipuserinfo.youpaipavatar]];
- self.userAvatarImage.image = [self createQRCodeWithData:self.viewModel.qrCodeContent size:adapt(120)];
-
- self.userNicknameLb.text = [LCSaveModel getUserModel].youpaipuserinfo.youpaipnickname;
-
- self.userCodeLb.text = stringFormat(@"用户号:%@",[LCSaveModel getUserModel].youpaipuserinfo.youpaipusercode);
-
- //UIImage *qrCode = [self createQRCodeWithData:self.viewModel.qrCodeContent size:adapt(100)];
- self.qrCodeImage.image = ImageByName(@"ym_inviting_prizes_share_app_icon");
- }
- - (UIImage *)cutImage {
- UIImage *imageRet = nil;
- int scale = [UIScreen mainScreen].scale;
- CGSize Ksize = CGSizeMake(self.posterImage.frame.size.width*scale, self.posterImage.frame.size.height*scale);
- // 传入的View.frame.size是0的话,直接返回nil,防止 UIGraphicsBeginImageContext() 传入0,导致崩溃
- if (CGSizeEqualToSize(Ksize, CGSizeZero)) {
- return nil;
- }
- UIGraphicsBeginImageContextWithOptions(Ksize, NO, scale);
- [self.posterImage.image drawInRect:CGRectMake(0,0, Ksize.width, Ksize.height)];
- imageRet = UIGraphicsGetImageFromCurrentImageContext();
- UIGraphicsEndImageContext();
- return imageRet;
- }
- - (UIImage *)cutImage:(UIView *)view {
- int scale = [UIScreen mainScreen].scale;
- CGSize shotSize = CGSizeMake(view.frame.size.width*scale, view.frame.size.height*scale);
- // 传入的View.frame.size是0的话,直接返回nil,防止 UIGraphicsBeginImageContext() 传入0,导致崩溃
- if (CGSizeEqualToSize(shotSize, CGSizeZero)) {
- return nil;
- }
- UIGraphicsBeginImageContextWithOptions(shotSize, NO, scale);
- [view.layer renderInContext:UIGraphicsGetCurrentContext()];
- UIImage *tempImage = UIGraphicsGetImageFromCurrentImageContext();
- UIGraphicsEndImageContext();
- CGImageRef imageRef = tempImage.CGImage;
- CGRect rect = CGRectMake(0,0, shotSize.width, shotSize.height);
- CGImageRef imageRefRect = CGImageCreateWithImageInRect(imageRef, rect);
- UIImage *image = [[UIImage alloc]initWithCGImage:imageRefRect];
- return image;
- }
- - (UIImage *)createQRCodeWithData:(NSString *)data size:(CGFloat)size{
- NSData *string_data = [data dataUsingEncoding:NSUTF8StringEncoding];
- // 1、二维码滤镜
- CIFilter *fileter = [CIFilter filterWithName:@"CIQRCodeGenerator"];
- [fileter setValue:string_data forKey:@"inputMessage"];
- /*
- L (低):可以纠正7%左右的错误
- M (中):可以纠正15%左右的错误
- Q (高):可以纠正25%左右的错误
- H (高):可以纠正30%左右的错误
- */
- [fileter setValue:@"H" forKey:@"inputCorrectionLevel"];
- CIImage *ciImage = fileter.outputImage;
- // 2、颜色滤镜
- CIFilter *color_filter = [CIFilter filterWithName:@"CIFalseColor"];
- [color_filter setValue:ciImage forKey:@"inputImage"];
- [color_filter setValue:[CIColor colorWithCGColor:HexColorFromRGB(0x000000).CGColor] forKey:@"inputColor0"];
- [color_filter setValue:[CIColor colorWithCGColor:HexColorFromRGB(0xFFFFFF).CGColor] forKey:@"inputColor1"];
- // 3、生成处理
- CIImage *outImage = color_filter.outputImage;
- CGFloat scale = size / outImage.extent.size.width;
- outImage = [outImage imageByApplyingTransform:CGAffineTransformMakeScale(scale, scale)];
- return [UIImage imageWithCIImage:outImage];
- }
- - (UIView *)baseView{
- if (!_baseView) {
- _baseView = [[UIView alloc]init];
- _baseView.backgroundColor = HexColorFromRGB(0xFFFFFF);
- [_baseView addRectCorner:UIRectCornerAllCorners radius:adapt(16)];
- }
- return _baseView;
- }
- - (UIImageView *)posterImage{
- if (!_posterImage) {
- _posterImage = [[UIImageView alloc]init];
- //_posterImage.contentMode = UIViewContentModeScaleAspectFit;
- }
- return _posterImage;
- }
- - (UIImageView *)userAvatarImage{
- if (!_userAvatarImage) {
- _userAvatarImage = [[UIImageView alloc]init];
- _userAvatarImage.contentMode = UIViewContentModeScaleAspectFit;
- }
- return _userAvatarImage;
- }
- - (UILabel *)userNicknameLb{
- if (!_userNicknameLb) {
- _userNicknameLb = [[UILabel alloc]init];
- _userNicknameLb.font = LCBoldFont(13);
- _userNicknameLb.textColor = HexColorFromRGB(0x333333);
- _userNicknameLb.textAlignment = NSTextAlignmentLeft;
- _userNicknameLb.text = @"*****";
- /**
- *抗拉伸 setContentHuggingPriority(值越高,越不容易拉伸)
- */
- [_userNicknameLb setContentHuggingPriority:UILayoutPriorityDefaultLow forAxis:UILayoutConstraintAxisHorizontal];
- /**
- *抗压缩 setContentCompressionResistancePriority(值越高,越不容易压缩)
- **/
- [_userNicknameLb setContentCompressionResistancePriority:UILayoutPriorityDefaultLow forAxis:UILayoutConstraintAxisHorizontal];
- }
- return _userNicknameLb;
- }
- - (UILabel *)userCodeLb{
- if (!_userCodeLb) {
- _userCodeLb = [[UILabel alloc]init];
- _userCodeLb.font = LCFont(12);
- _userCodeLb.textColor = HexColorFromRGB(0x666666);
- _userCodeLb.textAlignment = NSTextAlignmentLeft;
- _userCodeLb.text = @"*****";
- /**
- *抗拉伸 setContentHuggingPriority(值越高,越不容易拉伸)
- */
- [_userCodeLb setContentHuggingPriority:UILayoutPriorityDefaultLow forAxis:UILayoutConstraintAxisHorizontal];
- /**
- *抗压缩 setContentCompressionResistancePriority(值越高,越不容易压缩)
- **/
- [_userCodeLb setContentCompressionResistancePriority:UILayoutPriorityDefaultLow forAxis:UILayoutConstraintAxisHorizontal];
- }
- return _userCodeLb;
- }
- - (UIImageView *)qrCodeImage{
- if (!_qrCodeImage) {
- _qrCodeImage = [[UIImageView alloc]init];
- }
- return _qrCodeImage;
- }
- @end
|