yon*_*hen 1 properties objective-c uiimage nsmutablearray ios
我有这样NSMutableArray的UIImage命名camImages.然后我想得到scale一个图像的属性,但我似乎无法访问使用
[[camImages objectAtIndex:i] scale] //doesn't return the desired scale property
[camImages.objectAtIndex:i].scale //doesn't work (Error: Property 'scale' not found on object of type 'id')
Run Code Online (Sandbox Code Playgroud)
如果我有一个UIImage,那么可以获得该属性
UIImage *img;
img.scale //desired property
Run Code Online (Sandbox Code Playgroud)
我是iOS和Objective-C的新手,我怎样才能获得所需的属性?提前致谢!
编辑:
[[camImages objectAtIndex:i] scale]将返回
NSDecimalNumberBehaviors
规模
返回小数分隔符后允许的位数.(需要)
- (short)scale返回值小数分隔符后允许的位数.
而所需的规模是CGFloat类型:
的UIImage
规模
图像的比例因子.(只读)
@property(nonatomic,readonly)CGFloat scale讨论如果从名称中包含@ 2x修饰符的文件加载图像,则比例设置为2.0.您还可以在从Core Graphics图像初始化图像时指定显式比例因子.假设所有其他图像的比例因子为1.0.
如果将图像的逻辑大小(存储在size属性中)乘以此属性中的值,则可以获得图像的尺寸(以像素为单位).
使代码更易于阅读和调试:
UIImage *image = camImages[i];
CGFloat scale = image.scale;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1301 次 |
| 最近记录: |