2015-12-06 24 views
0

如何在一些小圖像之前和之後刪除空白空間。Swift:刪除Aspect Fit中的空白空間ImageView

一些圖像運行良好,下面的例子和一些在圖像上方和下方有巨大的空間。 現在用的解析,所以我想我不能直接訪問的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 

enter image description here

+0

這是一門課程嗎? –

+0

課程否! ,我不確定你是什麼意思? :) –

+0

幾天前彈出的問題完全一樣 –

回答

-1

可以根本就以下到您的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]; 

來源:iOS NSAttributedString on UIButton

+0

我不確定這個答案是否適合我的問題? –