0

How to remove empty white space before and after some images that are small.

Some images are working well as the example below and some are with huge space above and below the image. Am using Parse so I think I can't access imageView directly :

// 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

rmaddy
  • 314,917
  • 42
  • 532
  • 579
James Moriarty
  • 566
  • 2
  • 7
  • 27

1 Answers1

-1

You can simply do the following to your UIButton to give it multiple lines and different fonts:

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];

Source: iOS NSAttributedString on UIButton

Community
  • 1
  • 1
Mika
  • 5,807
  • 6
  • 38
  • 83