문제

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.

올바른 솔루션이 없습니다

다른 팁

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
);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top