UIButton Bildgröße anpassen / skalieren
Ich habe ein wirklich verdrahtetes Problem und weiß nicht, wie ich es lösen soll. Ich animiere einen UIButtons-Frame und möchte, dass das Bild in der Schaltfläche auf die Größe der Schaltfläche skaliert wird, wenn ich es animiere. Auf meinem iPhone-Simulator funktioniert es, ohne etwas zu tun. Wenn ich es auf dem iPad-Simulator ausführe, ändert sich die Bildgröße jedoch nicht. Ich habe [[gissaImg1 imageView] setContentMode: UIViewContentModeScaleToFill] Code an mehreren Stellen hinzugefügt, aber es hat nicht geholfen.
Weiß jemand, was falsch ist und wie man dieses Problem behebt?
<code>//Code to set the image UIImage *image = [UIImage imageNamed:[NSString stringWithFormat:@"%@_small", [[itemsForRound objectAtIndex:[[guessItems objectAtIndex:0] intValue]] valueForKey:@"Name"]]]; [self.gissaImg1 setImage:image forState:UIControlStateNormal]; [self.gissaImg1 setImage:image forState:UIControlStateHighlighted]; //Code to animate button CGRect animateToSpot = (isIphone) ? CGRectMake(0, 0, 480, 320) : CGRectMake(0, 0, 1024, 768); [self performSelector:@selector(PlayCorrectSound:) withObject:nil afterDelay:1]; [[gissaImg1 imageView] setContentMode:UIViewContentModeScaleToFill]; [UIView animateWithDuration:1.5 delay:0 options:(UIViewAnimationOptionAllowUserInteraction | UIViewAnimationCurveLinear) animations:^{ switch (index) { case 0: [[gissaImg1 imageView] setContentMode:UIViewContentModeScaleToFill]; [self.gissaImg1 setFrame:animateToSpot]; [self.view bringSubviewToFront:gissaImg1]; break; ....... </code>