我正在寻找检测图像的宽度和高度,并将这些尺寸传递给以下代码:

   UIImageView *imgView=[[UIImageView alloc] initWithFrame:CGRectMake(25, 5, imgView.size.width, imgView.size.width)];


我的语法有问题或执行此操作的错误方法。任何帮助都会很棒,
谢谢

最佳答案

做:

UIImage *someImage = [UIImage imageNamed:@"someImage.png"];
UIImageView *someImageView = [[UIImageView alloc] initWithImage:someImage];
someImageView.frame = CGRectMake(0, 0, someImage.size.width, someImage.size.height);

10-08 05:32