我试图从this教程实现一些基本的UIGestureRecongnizer控件。我在理解这个类并将其翻译成Swift 3时遇到了一些麻烦
sudo pip install <package>
(ps:带有GLK前缀的方法来自Apples GLKit框架)
interface Transformations : NSObject
- (id)initWithDepth:(float)z Scale:(float)s Translation:(GLKVector2)t Rotation:(GLKVector3)r;
- (void)start;
- (void)scale:(float)s;
- (void)translate:(GLKVector2)t withMultiplier:(float)m;
- (void)rotate:(GLKVector3)r withMultiplier:(float)m;
- (GLKMatrix4)getModelViewMatrix;
@end
到目前为止,这是怎么回事?
这是我想要翻译成Swift 3的.m文件。
class Transformations: NSObject {
init(Scale: Float, Translation: GLKVector2, Rotation: GLKVector3) {
func scale(s: Float) {
}
func translate(t: GLKVector2, withMultiplier: Float) {
}
func rotate(r: GLKVector3, withMultiplier: Float) {
}
}
}
答案 0 :(得分:1)
所以你应该翻译.m文件。像这样:
class Transformations: NSObject {
var _depth: Float
init(z: Float, scale s: Float, translation t: GLKVector2, rotation r: GLKVector3) {
self._depth = z
}
func start() {
}
func scale(s: Float) {
}
func translate(t: GLKVector2, withMultiplier m: Float) {
}
func rotate(r: GLKVector3, withMultiplier m: Float) {
}
func getModelViewMatrix() -> GLKMatrix4 {
var modelViewMatrix = GLKMatrix4Identity
modelViewMatrix = GLKMatrix4Translate(modelViewMatrix, 0, 0, -_depth)
return modelViewMatrix
}
}