// // DescView.m // ThePaperHD // // Created by YoungLee on 15/6/18. // Copyright (c) 2015年 scar1900. All rights reserved. // #import "DescView.h" @implementation DescView - (id)initWithDescString:(NSString *)descString tagString:(NSString *)tagString { self = [super initWithFrame:CGRectZero]; if (nil != self) { UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation]; UILabel *tagLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 4.5, [iphoneLineSpaceAndParaSpace returnLevel3Plus5FontSize]*4, [iphoneLineSpaceAndParaSpace returnLevel3Plus5FontSize]+4)]; tagLabel.font = appFont([iphoneLineSpaceAndParaSpace returnLevel3Plus5FontSize], NO); tagLabel.textColor = [UIColor whiteColor]; tagLabel.text = tagString; [self addSubview:tagLabel]; UILabel *descLabel = [[UILabel alloc] initWithFrame:CGRectMake(12, 5, rect_screen.size.width-24, 14)]; descLabel.font = appFont([iphoneLineSpaceAndParaSpace returnLevel2Plus5FontSize], NO); descLabel.numberOfLines = 0; descLabel.lineBreakMode = NSLineBreakByCharWrapping; descLabel.textColor = [UIColor whiteColor]; // descLabel.text = @"高度"; // NSAttributedString *oneLineAttr = getLineSpaceAttributedString(@"高度", [iphoneLineSpaceAndParaSpace returnLevel2Plus5LineSpace], appFont([iphoneLineSpaceAndParaSpace returnLevel2Plus5FontSize], NO)); // descLabel.attributedText = oneLineAttr; CGFloat oneLine = [iphoneLineSpaceAndParaSpace returnLevel2Plus5LineSpace] + appFont([iphoneLineSpaceAndParaSpace returnLevel2Plus5FontSize], NO).lineHeight; NSAttributedString *attr = getLineSpaceAttributedString(descString, [iphoneLineSpaceAndParaSpace returnLevel2Plus5LineSpace], appFont([iphoneLineSpaceAndParaSpace returnLevel2Plus5FontSize], NO)); descLabel.attributedText = attr; CGSize size = [descLabel sizeThatFits:CGSizeMake(rect_screen.size.width-24, CGFLOAT_MAX)]; if (orientation == UIInterfaceOrientationLandscapeRight || orientation ==UIInterfaceOrientationLandscapeLeft) { if (size.height > oneLine*3) {//三行 self.frame = CGRectMake(0, rect_screen.size.height - oneLine*3-3, rect_screen.size.width, oneLine*3 + 3); self.scrollEnabled = YES; } else { self.frame = CGRectMake(0, rect_screen.size.height - oneLine*3-3, rect_screen.size.width, size.height+6); self.scrollEnabled = NO; } if (isBlankString(descString)) { self.frame = CGRectMake(0, rect_screen.size.height - oneLine*3 -3, rect_screen.size.width, [iphoneLineSpaceAndParaSpace returnLevel3Plus5FontSize]+6); } }else { if (size.height > oneLine*5) {//五行 self.frame = CGRectMake(0, rect_screen.size.height - oneLine*5-3, rect_screen.size.width, oneLine*5 + 3); self.scrollEnabled = YES; } else { self.frame = CGRectMake(0, rect_screen.size.height - oneLine*5-3, rect_screen.size.width, size.height+6); self.scrollEnabled = NO; } if (isBlankString(descString)) { self.frame = CGRectMake(0, rect_screen.size.height -oneLine*5 - 3, rect_screen.size.width, [iphoneLineSpaceAndParaSpace returnLevel3Plus5FontSize]+6); } } descLabel.frame = CGRectMake(12, 5, rect_screen.size.width-24, size.height); self.contentSize = CGSizeMake(0, size.height+5); self.indicatorStyle = UIScrollViewIndicatorStyleWhite; //bug:4995(图集:图说超过5行没有滚动条) [self addSubview:descLabel]; } return self; } @end