我试图让UIImage对象的界限改变取决于图像大小。我不知道为什么图像边界不会更新
@interface AsunaEventViewController ()
@property (weak, nonatomic) IBOutlet UIImageView *AsunaImageView;
@end
@implementation AsunaEventViewController
CGFloat x = self.AsunaImageView.bounds.center.x;
CGFloat y = self.AsunaImageView.bounds.center.y;
if (self.answer == 0){
CGSize imageSize = [[UIImage imageNamed:@"qwr.png"] size];
CGRect imageBounds = CGRectMake(x - imageSize.width/2, y - imageSize.height/2, imageSize.width, imageSize.height);
self.AsunaImageView.frame = imageBounds;
self.AsunaImageView.image = [UIImage imageNamed:@"rts.png"]
答案 0 :(得分:2)
更改UIImageview的图像名称
if (self.answer == 0){
CGSize imageSize = [[UIImage imageNamed:@"qwr.png"] size];
CGRect imageBounds = CGRectMake(x - imageSize.width/2, y - imageSize.height/2, imageSize.width, imageSize.height);
self.AsunaImageView.frame = imageBounds;
self.AsunaImageView.image = [UIImage imageNamed:@"qwr.png"];
}