123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228 |
- //
- // KBShareGetFriendsView.m
- // YouHuiProject
- //
- // Created by jcymac on 2018/5/24.
- // Copyright © 2018年 kuxuan. All rights reserved.
- //
- //#define QRwidth (120)
- #import "KBShareGetFriendsView.h"
- @interface KBShareGetFriendsView()
- {
- NSInteger count;
- }
- @property(nonatomic,strong)UIImageView *centerImageView;
- @property(nonatomic,strong)UIImageView *yhIconImageView;
- @property(nonatomic,strong)UILabel *yhTitleLabel;
- @property(nonatomic,strong)UILabel *getFirendCodeLabel;
- @property(nonatomic,strong)UIImageView *QRcodeImageView;
- @property(nonatomic,strong)UILabel *bottomLabel;
- @property(nonatomic,strong)UIImageView *userIcon;
- @property(nonatomic,strong)UILabel *nickName;
- @property(nonatomic,strong)UILabel *inviteCode;
- @end
- @implementation KBShareGetFriendsView
- static NSInteger QRwidth;
- -(instancetype)initWithFrame:(CGRect)frame{
- if (self=[super initWithFrame:frame]) {
- if (iPhone6) {
- QRwidth=100;
- }else if(iPhone5){
- QRwidth=80;
- }else{
- QRwidth=120;
- }
-
- }
- return self;
- }
- -(void)setModel:(KBShareGetFriendsModel *)model{
- _model=model;
- [self addUI];
- [self otherOP];
- }
- -(void)addUI{
- [self addSubview:self.centerImageView];
- [self addSubview:self.yhIconImageView];
- [self addSubview:self.yhTitleLabel];
- // [self addSubview:self.getFirendCodeLabel];
- [self addSubview:self.QRcodeImageView];
- [self addSubview:self.bottomLabel];
- [self addSubview:self.inviteCode];
- [self addSubview:self.userIcon];
- [self addSubview:self.nickName];
- }
- - (void)setUserinfo:(NSDictionary *)userinfo {
- _userinfo = userinfo;
- self.inviteCode.text = [NSString stringWithFormat:@"邀请码:%@",userinfo[@"invite_code"]];
- [self.userIcon sd_setImageWithURL:[NSURL URLWithString:userinfo[@"headimg"]] completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
- count++;
- if (count > 1) {
- if (self.imgSuccBlock) {
- self.imgSuccBlock();
- }
- }
- }];
- self.nickName.text = userinfo[@"nickname"];
- }
- -(void)otherOP{
- if (self.model.imgUrl) {//url存在
- [self.centerImageView sd_setImageWithURL:[NSURL URLWithString:self.model.imgUrl] placeholderImage:[UIImage imageNamed:@""] completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
-
- if (self.model.headimg.length > 0) {
- [self.userIcon sd_setImageWithURL:[NSURL URLWithString:self.model.headimg] placeholderImage:[UIImage imageNamed:@"lgoin"] completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
- if (self.imgSuccBlock) {
- self.imgSuccBlock();
- }
- }];
- }else {
- count++;
- if (count > 1) {
- if (self.imgSuccBlock) {
- self.imgSuccBlock();
- }
- }
- }
-
- }];
- }else if(self.model.img) {//img存在
- [self.centerImageView setImage:self.model.img];
- [self.userIcon sd_setImageWithURL:[NSURL URLWithString:self.model.headimg] placeholderImage:[UIImage imageNamed:@"lgoin"] completed:^(UIImage * _Nullable image, NSError * _Nullable error, SDImageCacheType cacheType, NSURL * _Nullable imageURL) {
- if (self.imgSuccBlock) {
- self.imgSuccBlock();
- }
- }];
- }else{
- if (self.imgSuccBlock) {
- self.imgSuccBlock();
- }
- }
-
- }
- -(UIImageView *)centerImageView{
- if (!_centerImageView) {// (self.width-FITSIZE(44))*(425.0f/330.0f)
- _centerImageView=[[UIImageView alloc]initWithFrame:CGRectMake(FITSIZE(22), FITHeightSIZE(64),self.width-FITSIZE(44), FITHeightSIZE(425))];
- _centerImageView.contentMode=UIViewContentModeScaleAspectFit;
- _centerImageView.backgroundColor=[UIColor clearColor];
- }
- return _centerImageView;
- }
- - (UIImageView *)yhIconImageView{
- if (!_yhIconImageView) {
- _yhIconImageView=[[UIImageView alloc]initWithFrame:CGRectMake(FITSIZE(30), self.inviteCode.bottom+FITHeightSIZE(15), 22, 22)];
- [_yhIconImageView setImage:[UIImage imageNamed:@"share_appicon"]];
- }
- return _yhIconImageView;
-
- }
- - (UILabel *)yhTitleLabel{
- if (!_yhTitleLabel) {
- _yhTitleLabel=[[UILabel alloc]initWithFrame:CGRectMake(self.yhIconImageView.right+FITSIZE(11), 0, 0, 0)];
- _yhTitleLabel.textColor=[UIColor YHColorWithHex:0x333333];
- _yhTitleLabel.font=[UIFont systemFontOfSize:14];
- NSDictionary *infoDictionary = [[NSBundle mainBundle] infoDictionary];
- NSString *app_Name = [infoDictionary objectForKey:@"CFBundleDisplayName"];
- _yhTitleLabel.text=app_Name;
- [_yhTitleLabel sizeToFit];
- _yhTitleLabel.centerY=self.yhIconImageView.centerY;
- }
- return _yhTitleLabel;
- }
- - (UILabel *)getFirendCodeLabel{
- if (!_getFirendCodeLabel) {
- _getFirendCodeLabel=[[UILabel alloc]initWithFrame:CGRectMake(self.yhTitleLabel.right+20, self.yhIconImageView.bottom+15, 0, 0)];
-
- _getFirendCodeLabel.font=[UIFont systemFontOfSize:14];
- _getFirendCodeLabel.textColor=[UIColor YHColorWithHex:0x262626];
- _getFirendCodeLabel.text=[NSString stringWithFormat:@"选的对 赚得多"];
- [_getFirendCodeLabel sizeToFit];
- _getFirendCodeLabel.centerY = self.yhIconImageView.centerY;
- }
- return _getFirendCodeLabel;
- }
- - (UIImageView *)QRcodeImageView{
- if (!_QRcodeImageView) {
- _QRcodeImageView=[[UIImageView alloc]initWithFrame:CGRectMake(self.width-FITSIZE((30+QRwidth)), self.centerImageView.bottom+28, FITSIZE(QRwidth), FITSIZE(QRwidth))];
- //1. 实例化二维码滤镜
- CIFilter *filter = [CIFilter filterWithName:@"CIQRCodeGenerator"];
- // 2. 恢复滤镜的默认属性
- [filter setDefaults];
- // 3. 将字符串转换成NSData
- NSString *urlStr =@"http://www.ourname.xin";
- if (self.model.QRcodeUrl) {
- urlStr=self.model.QRcodeUrl;
- }
- NSData *data = [urlStr dataUsingEncoding:NSUTF8StringEncoding];
- // 4. 通过KVO设置滤镜inputMessage数据
- [filter setValue:data forKey:@"inputMessage"];
- // 5. 获得滤镜输出的图像
- CIImage *outputImage = [filter outputImage];
- UIImage *img=[outputImage createNonInterpolatedUIImagewithSize:FITSIZE(QRwidth)];
- [_QRcodeImageView setImage:img];
- _QRcodeImageView.backgroundColor=[UIColor yhGrayColor];
- }
- return _QRcodeImageView;
- }
- - (UILabel *)bottomLabel{
- if (!_bottomLabel) {
- _bottomLabel=[[UILabel alloc]initWithFrame:CGRectMake(0, self.height-37, self.width, 37)];
- _bottomLabel.text=@"1.微信扫码下载 →2.微信登录 →3.开启优选之旅";
- [_bottomLabel adjustsFontSizeToFitWidth];
- _bottomLabel.textAlignment=NSTextAlignmentCenter;
- _bottomLabel.backgroundColor=[UIColor YHColorWithHex:0xF2F2F2];
- _bottomLabel.textColor=[UIColor YHColorWithHex:0x666666];
- _bottomLabel.font=[UIFont systemFontOfSize:14];
- }
- return _bottomLabel;
- }
- - (UIImageView *)userIcon {
- if (!_userIcon) {
- _userIcon = [[UIImageView alloc] initWithFrame:CGRectMake(Fitsize(30), self.centerImageView.bottom+28, FITHeightSIZE(30), FITHeightSIZE(30))];
- _userIcon.layer.cornerRadius = FITHeightSIZE(15);
- _userIcon.backgroundColor = [UIColor yhGrayColor];
- _userIcon.layer.masksToBounds = YES;
- }
- return _userIcon;
- }
- - (UILabel *)nickName {
- if (!_nickName) {
- _nickName = [[UILabel alloc] initWithFrame:CGRectMake(self.userIcon.right+5, 0, Fitsize(180), 20)];
- _nickName.textColor = [UIColor YHColorWithHex:0x333333];
- _nickName.font = [UIFont systemFontOfSize:Fitsize(14)];
- _nickName.centerY = self.userIcon.centerY;
- _nickName.text = self.model.nickname;
- }
- return _nickName;
- }
- - (UILabel *)inviteCode {
- if (!_inviteCode) {
- _inviteCode = [[UILabel alloc] initWithFrame:CGRectMake(Fitsize(30), self.userIcon.bottom+FITHeightSIZE(15), FITHeightSIZE(180), 20)];
- _inviteCode.textColor = [UIColor YHColorWithHex:0x333333];
- _inviteCode.font = [UIFont systemFontOfSize:Fitsize(14)];
- _inviteCode.text = [NSString stringWithFormat:@"邀请码:%@",self.model.inviteCode];
- }
- return _inviteCode;
- }
- @end
|