0

我试图使 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"]
4

1 回答 1

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"];
}
于 2013-10-04T05:59:03.200 回答