Question

I have an image with width as '50px' and height as '40px' in my Webpage.

Now i want to display the image with same dimensions in UIImageView.

How can i convert the pixels into CGFloat?

Thanks for your answers.

No correct solution

OTHER TIPS

You can create it like this:

UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(xCoordinate, yCoordinate, 50.0, 40.0)];

NSString *imageURL = @"www.YourURLHere.com/YourPicture.jpg";

NSData *imageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:imageURL]];

imageView.image = [UIImage imageWithData:imageData];

The CGFloat values have a 1 to 1 relationship with pixels.

Thus 100 x 100 pixels should be CGRect of 100 x 100, example:

CGRect CGRectMake (
   CGFloat x,
   CGFloat y,
   CGFloat width,
   CGFloat height
);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top