Monday, May 14, 2012

Why after rotating UIImageView size is getting changed?

I'm new in using transformations. And still confusted how they are working.



What I'm trying to do, is to rotate my UIImageView with given angle. But after rotating, it's changing the size of image, getting smaller. I'm also doing scaling for ImageView so it won't be upside down.How to rotate and keep the size, that was given in CGRectMake, when ImageView was allocated ?



    UIImageView *myImageView = [[UIImageView alloc]initWithFrame:CGRectMake(x,y,width,height)];        

myImageView.contentMode = UIViewContentModeScaleAspectFit;

[myImageView setImage:[UIImage imageNamed:@"image.png"]];

myImageView.layer.anchorPoint = CGPointMake(0.5,0.5);

CGAffineTransform newTransform;

myImageView.transform = CGAffineTransformMakeScale(1,-1);

newTransform = CGAffineTransformRotate(newTransform, 30*M_PI/180);

[self.window addSubview:myImageView];


Thanks a lot!





No comments:

Post a Comment