使用约束来自动填写button的宽度

[weakSelf.onePosition sd_setImageWithURL:[NSURL URLWithString:model.icon] forState:UIControlStateNormal completed:^(UIImage *image, NSError *error, SDImageCacheType cacheType, NSURL *imageURL) {

if (image && image.size.height > 0) {

CGFloat width = (image.size.width / image.size.height) * weakSelf.onePosition.frame.size.height;

weakSelf.onePositionButtonWidth.constant = width;

}

}];

你可能感兴趣的:(使用约束来自动填写button的宽度)