Ios Swift:删除Aspect Fit ImageView中的空白

Ios Swift:删除Aspect Fit ImageView中的空白,ios,swift,uiimageview,uiimage,Ios,Swift,Uiimageview,Uiimage,如何删除一些小图像前后的空白 有些图像与下面的示例一样工作正常,有些图像上下都有巨大的空间。 我正在使用Parse,因此我认为无法直接访问imageView: // upload Image To Parse as PFImageView let imgFile = object?.objectForKey("ImgView") as? PFFile cell.ImgView.file = imgFile cell.questionImgView.loadI

如何删除一些小图像前后的空白

有些图像与下面的示例一样工作正常,有些图像上下都有巨大的空间。 我正在使用Parse,因此我认为无法直接访问imageView:

// upload Image To Parse as PFImageView
   let imgFile = object?.objectForKey("ImgView") as? PFFile
        cell.ImgView.file = imgFile
        cell.questionImgView.loadInBackground()
       // cell.questionImgView.clipsToBounds = true
      cell. cell.ImgView.clipsToBounds.contentMode = UIViewContentMode.ScaleAspectFit

您只需对UIButton执行以下操作,即可为其提供多行和不同字体:

NSMutableParagraphStyle *style = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
[style setAlignment:NSTextAlignmentCenter];
[style setLineBreakMode:NSLineBreakByWordWrapping];

UIFont *font1 = [UIFont fontWithName:@"HelveticaNeue-Medium" size:20.0f];
UIFont *font2 = [UIFont fontWithName:@"HelveticaNeue-Light"  size:20.0f];
NSDictionary *dict1 = @{NSUnderlineStyleAttributeName:@(NSUnderlineStyleSingle),  
                    NSFontAttributeName:font1};
NSDictionary *dict2 = @{NSUnderlineStyleAttributeName:@(NSUnderlineStyleNone),    
                    NSFontAttributeName:font2};

NSMutableAttributedString *attString = [[NSMutableAttributedString alloc] init];
[attString appendAttributedString:[[NSAttributedString alloc] initWithString:@"LINE 1\n"    attributes:dict1]];
[attString appendAttributedString:[[NSAttributedString alloc] initWithString:@"line 2"      attributes:dict2]];
[[self buttonToStyle] setAttributedTitle:attString forState:UIControlStateNormal];
[[[self buttonToStyle] titleLabel] setNumberOfLines:0];
[[[self buttonToStyle] titleLabel] setLineBreakMode:NSLineBreakByWordWrapping];

来源:

这是课程吗?课程号,我不知道你的意思是什么?:)几天前也出现了同样的问题我不确定这个答案是否适合我的问题?!