我的网页上有一个宽度为'50px',高度为'40px'的图片。如何将像素转换为CGFloat?
现在我想在UIImageView中显示具有相同尺寸的图像。
如何将像素转换为CGFloat?
感谢您的回答。
我的网页上有一个宽度为'50px',高度为'40px'的图片。如何将像素转换为CGFloat?
现在我想在UIImageView中显示具有相同尺寸的图像。
如何将像素转换为CGFloat?
感谢您的回答。
你可以这样创建:
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];
的CGFloat的值与像素的1对1的关系。
因此100×100像素应该是100×100的CGRect,例如:
CGRect CGRectMake (
CGFloat x,
CGFloat y,
CGFloat width,
CGFloat height
);
50.0和40.0,或我不理解你的问题? –
是的,它是50.0和40.0 – Kirubachari