作者:痴情被撕碎的阳光 | 来源:互联网 | 2023-05-17 00:23
]];
nicknameLabel.text = @"我是昵称。我的昵称是小可爱";
[goodIMG sd_setImageWithURL:[NSURL URLWithString:@"https://tva2.sinaimg.cn/crop.0.0.100.100.50/0068QiKMjw8esxxwpxcxdj302s02s3yb.jpg"] placeholderImage:[UIImage imageNamed:@"icon_default"]];
goodIntro.text = @"这个宝贝,人见人爱,花见花开。你一定会爱上她的。真的不信你看呀。我是一只宝贝详情,我是独一无二的存在。2018年一定要。。。。。。。。。。。。。。。。。。。。。。。。这个宝贝,人见人爱,花见花开。你一定会爱上她的。真的不信你看呀。我是一只宝贝详情,我是独一无二的存在。2018年一定要。。。。。。。。。。。。。。。。。。。。。。。。这个宝贝,人见人爱,花见花开。你一定会爱上她的。真的不信你看呀。我是一只宝贝详情,我是独一无二的存在。2018年一定要。。。。。。。。。。。。。。。。。。。。。。。。这个宝贝,人见人爱,花见花开。你一定会爱上她的。真的不信你看呀。我是一只宝贝详情,我是独一无二的存在。2018年一定要。。。。。。。。。。。。。。。。。。。。。。。。这个宝贝,人见人爱,花见花开。你一定会爱上她的。真的不信你看呀。我是一只宝贝详情,我是独一无二的存在。2018年一定要。。。。。。。。。。。。。。。。。。。。。。。。这个宝贝,人见人爱,花见花开。你一定会爱上她的。真的不信你看呀。我是一只宝贝详情,我是独一无二的存在。2018年一定要。。。。。。。。。。。。。。。。。。。。。。。。这个宝贝,人见人爱,花见花开。你一定会爱上她的。真的不信你看呀。我是一只宝贝详情,我是独一无二的存在。2018年一定要。。。。。。。。。。。。。。。。。。。。。。。。";
// goodIntro.text = @"这个宝贝,人见人爱";
//设置内容的位置及格式
//1.名字最多显示8个字。多余的显示...
if (nicknameLabel.text.length>8) {
nicknameLabel.text = [[nicknameLabel.text substringWithRange:NSMakeRange(0, 7)]stringByAppendingString:@"..."];
}
//2.商品图片的高度按照比例进行显示
[goodIMG sd_setImageWithURL:[NSURL URLWithString:@"https://tva2.sinaimg.cn/crop.0.0.100.100.50/0068QiKMjw8esxxwpxcxdj302s02s3yb.jpg"] completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
CGFloat scorW = goodIMG.width/image.size.width;
CGFloat scroH = scorW *image.size.height;
//从新设置goodimg的高度
goodIMG.height = scroH;
goodIntro.top = CGRectGetMaxY(goodIMG.frame)+10;
goodIntro.height = [JAppUtility getTextHeightWithView:goodIntro];
contentView.height = CGRectGetMaxY(goodIntro.frame)+10;
CGFloat offY =CGRectGetMaxY(contentView.frame)-SCREENH;
NSLog(@"%f",offY);
if(offY>0){
bgScrollView.contentSize = CGSizeMake(SCREENW, SCREENH+offY+64);
}else{
bgScrollView.contentSize = CGSizeMake(SCREENW, SCREENH);
}
}];
}
#pragma mark - 界面ui
- (void)createUI{
// self.view.backgroundColor = [UIColor grayColor];
bgScrollView = [JAppViewTools getScrollView:CGRectMake(0, 64, SCREENW, SCREENH) :self];
bgScrollView.contentSize = CGSizeMake(SCREENW, SCREENH);
bgScrollView.backgroundColor = [UIColor grayColor];
[self.view addSubview:bgScrollView];
//1.大view
contentView = [JAppViewTools getView:CGRectMake(0, 0, SCREENW, 300) :[UIColor whiteColor]];
[bgScrollView addSubview:contentView];
//2.头像
iconIMG = [JAppViewTools getImageView:CGRectMake(15, 15, 44, 44) image:@"icon_default"];
[contentView addSubview:iconIMG];
//3.昵称
nicknameLabel = [JAppViewTools getLabel:CGRectMake(CGRectGetMaxX(iconIMG.frame)+10, CGRectGetMidY(iconIMG.frame)-10, SCREENW-(CGRectGetMaxX(iconIMG.frame)+10), 20) :JTextFCMake([UIFont systemFontOfSize:15], [UIColor blackColor])];
nicknameLabel.text = @"名字占位符";
[contentView addSubview:nicknameLabel];
//4.商品图
goodIMG = [JAppViewTools getImageView:CGRectMake(CGRectGetMinX(iconIMG.frame), CGRectGetMaxY(iconIMG.frame)+10, SCREENW-CGRectGetMinX(iconIMG.frame)*2, 100) image:@"icon_default"];
[contentView addSubview:goodIMG];
//5.商品简介
goodIntro = [JAppViewTools getLabel:CGRectMake(CGRectGetMinX(iconIMG.frame), CGRectGetMaxY(goodIMG.frame)+10, SCREENW-30, 30) :@"商品简介占位符" :JTextFCMake([UIFont systemFontOfSize:15], [UIColor redColor])];
[contentView addSubview:goodIntro];
contentView.height = CGRectGetMaxY(goodIntro.frame)+10;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end
喜欢的,想要demo的可以 邮箱联系我:673658917@qq.com.