2010-06-14 16 views
5

Ho uno strano problema utilizzando UIButtons, digitare custom. Sto posizionando 4 di questi pulsanti su un UIScrollview, ruotando ciascun pulsante di un angolo casuale usando CGAffineTransform. Ora sembra che i pulsanti stessi cambino dimensione a seconda dell'angolo di rotazione.CGAffineTransform: rotazione su UIButton pulsante ridimensiona immagine

UIGraphicsBeginImageContext(tempCtxSize); 
[cookbookImage drawInRect:CGRectMake(imgOffsetX, imgOffsetY+frmOffsetY, cookbookImage.size.width, cookbookImage.size.height)]; 
[cookbookFrame drawInRect:CGRectMake(0.0f, frmOffsetY, cookbookFrame.size.width, cookbookFrame.size.height)]; 
UIImage *combinedImage = UIGraphicsGetImageFromCurrentImageContext(); 
UIGraphicsEndImageContext(); 

… 

UIButton *cookbookViewButton = [UIButton buttonWithType:UIButtonTypeCustom]; 
[cookbookViewButton setFrame:CGRectMake(0.0f, 0.0f, combinedImage.size.width, combinedImage.size.height)]; 

[cookbookViewButton setBackgroundColor:[UIColor clearColor]]; 
[cookbookViewButton setBackgroundImage:combinedImage forState:UIControlStateNormal]; 

CGAffineTransform rotation = [cookbookViewButton transform]; 
rotation = CGAffineTransformRotate(rotation, angle); // some random angle 
[cookbookViewButton setTransform:rotation]; 

risposta

0

Non impostare la cornice di cookbookViewButton - impostare i limiti.

2

Questo è un bug di sistema: "Important Se la proprietà di trasformazione di una vista non contiene la trasformazione dell'identità, il fotogramma di quella vista non è definito e lo sono anche i risultati dei suoi comportamenti di autoresizzazione."

da: Handling Layout Changes Automatically Using Autoresizing Rules

Soluzione: impostare autoResizeSubviews della vista genitore di NO.

parentView.autoresizesSubviews = NO; 
Problemi correlati