contentMode 設AspectFit
寬比高長
[self.picImageView sd_setImageWithURL:[NSURL URLWithString:url] placeholderImage:[UIImage imageNamed:@"pic_offer_n"] completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {
double width = image.size.width;
double height = image.size.height;
double apect = width/height;
double imageViewWidth = weakSelf.picImageView.frame.size.width;
double nHeight = imageViewWidth / apect;
[weakSelf.picImageView.heightAnchor constraintEqualToConstant:nHeight].active = YES;
}];
設定 height 的constraint,重設height
留言