When we set the aspect fit property of image view then the size of image get reduced because it sets the image according to the aspect ratio. So if we want to get the size after aspect fit the use the following code-
In the following code first initialize a image view and set content mode then use the AVMakeRectWithAspectRatioInsideRect property which results the frame of image.
Here is the code-
//initialize image view and set the frame
UIImageView *imgVW=[[UIImageView alloc]initWithFrame:self.view.frame];
//add imageview as a subview
[self.view addSubview:imgVW];
//create a image
UIImage *img=[UIImage imageNamed:@"ImageName"];
//set image in imageview
[imgVW setImage:img];
//set content mode of image view
[imgVW setContentMode:UIViewContentModeScaleAspectFit];
//get image frame
CGRect sizeBeingScaledTo = AVMakeRectWithAspectRatioInsideRect(img.size, CGRectMake(0, 0, imgVW.frame.size.width, imgVW.frame.size.height));
0 Comment(s)