iPerspective是一个增强现实控制的iOS库。
N/A
iPerspective可通过CocoaPods访问。要安装,只需将以下行添加到您的Podfile中:
pod 'iPerspective'
并在项目文件夹中执行此命令
pod install
查看'Exemple'目录中的示例项目iPerspective。
iPerspective中所有控件都使用'CoreMotion'。建议为您的应用中的所有控件创建单个CMMotionManager实例。
#import <CoreMotion/CoreMotion.h>
...
@interface EPViewController2 ()
{
CMMotionManager *motionmanager;
}
...
- (CMMotionManager *)sharedManager
{
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
motionmanager = [[CMMotionManager alloc] init];
});
return motionmanager;
}
UIImageViewPerspective是UIImageView的子类。您可以用它来替换您的UIImageView。
导入
#import <iPerspective/UIImageViewPerspective.h>
设置UIImageViewPerspective
// initialize _imagePerspective
[_imagePerspective setMotionManger:[self sharedManager]]; // (Mandatory) set motion manager
[_imagePerspective setMaximumAmplitude:20.0]; // (Optional) maximum move of UIImageView
[_imagePerspective setMaximumAngle:2.0]; // (OPtional) maximum angle managed
[_imagePerspective setUpdateInterval:0.01]; // (Optional) interval of refresh
启动通过CoreMotion的图像运动
// start image motion with core motion
[_imagePerspective startUpdate];
停止图像运动
// stop image motion
[_imagePerspective stopUpdate];
查看'Exemple'目录中的示例项目iPerspective。
UIImageView+Perspective是一个类别。您可以用它来替换您的UIImageView。
导入
#import <iPerspective/UIImageView+Perspective.h>
启动通过CoreMotion的图像运动
// start image motion with core motion
[_imagePerspective startUpdate:0.01 manager:[self sharedManager]];
停止图像运动
// stop image motion
[_imagePerspective stopUpdate:[self sharedManager]];
Eric Pinet,[email protected]
iPerspective可在MIT许可下使用。有关更多信息,请参阅LICENSE文件。