开发者

Make UITableView imageView square?

开发者 https://www.devze.com 2023-02-18 00:54 出处:网络
I have a app that will populate a UI开发者_开发百科TableView after the user takes a picture. The UITableViewCell\'s image is that picture that the user takes. I would prefer these images to be squar

I have a app that will populate a UI开发者_开发百科TableView after the user takes a picture.

The UITableViewCell's image is that picture that the user takes. I would prefer these images to be square.

I have tried just about everything, here's some code:

UIImage *theImage = [UIImage imageNamed:theImagePath];
cell.imageView.contentMode = UIViewContentModeScaleAspectFill;
cell.imageView.image = theImage;

Thanks! Coulton


one option would be to pass in a square image:

UIGraphicsBeginImageContext(CGSizeMake(60.0f, 60.0f));
[fullSizeImage drawInRect:CGRectMake(0,0,60.0f, 60.0f)];

UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext(); 

you would probably want to only do this once for each image, and then cache the result.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号