Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone UIPicker的替代方案_Iphone_Objective C_Ios_Xcode_Uipickerview - Fatal编程技术网

Iphone UIPicker的替代方案

Iphone UIPicker的替代方案,iphone,objective-c,ios,xcode,uipickerview,Iphone,Objective C,Ios,Xcode,Uipickerview,老虎机应用程序还有其他方法吗?这是因为UIPICKER方法不会产生缓慢的动画效果。您可以对每个数字/符号使用UIImageView,并为显示的图像的移动设置动画。使用UIPicker将仅限于字母和数字;使用UIImageView您可以添加其他典型的老虎机视觉效果,如樱桃等。您可以对每个数字/符号使用UIImageView,并为显示的图像的移动设置动画。使用UIPicker将仅限于字母和数字;使用UIImageView您可以添加其他典型的老虎机视觉效果,如樱桃等。我们正在做您的家庭作业吗 并排使用

老虎机应用程序还有其他方法吗?这是因为UIPICKER方法不会产生缓慢的动画效果。

您可以对每个数字/符号使用
UIImageView
,并为显示的图像的移动设置动画。使用
UIPicker
将仅限于字母和数字;使用
UIImageView
您可以添加其他典型的老虎机视觉效果,如樱桃等。

您可以对每个数字/符号使用
UIImageView
,并为显示的图像的移动设置动画。使用
UIPicker
将仅限于字母和数字;使用
UIImageView
您可以添加其他典型的老虎机视觉效果,如樱桃等。

我们正在做您的家庭作业吗

并排使用垂直UIScrollView,启用分页,视图使用UIImageView

默认情况下,它看起来是扁平的,但在功能上是等效的


您需要一些核心动画/核心图形,使其看起来更像UIPickerView。

我们正在做您的家庭作业吗

并排使用垂直UIScrollView,启用分页,视图使用UIImageView

默认情况下,它看起来是扁平的,但在功能上是等效的


您需要一些核心动画/核心图形,使其看起来更像UIPickerView。

这可以使用
CALayer
动画来完成

主slotMachineView层的类必须是
CATTransferMLlayer
,以允许子层的3D变换

假设您有10个方形图像,它们表示卷轴上的符号。对于每个图像,创建一个
CALayer
谁的内容属性是您的图像之一。然后,对于每个层,您需要应用2个变换:

  • 首先,您需要围绕其X轴旋转每个层(2*PI)/10
  • 然后将一些距离(您需要计算)沿 Z轴
现在将这些层添加到视图的层中。现在,您应该可以看到围绕X轴的“圆柱体”图像

要旋转圆柱体,您需要调整第一个变换-使用
CAAnimation
或使用计时器并通过计时器触发的偏移量调整X轴旋转

我将把它留给您去弄清楚完整的实现细节——但是这里有一些代码可以加载并创建一个初始的“卷轴”

int-imageCount=16;
对于(int i=0;i

要旋转它,只需更改变换的旋转部分。为了获得额外的积分,您可以在层远离中心时向其添加越来越多的阴影。

这可以使用
CALayer
动画来完成

主slotMachineView层的类必须是
CATTransferMLlayer
,以允许子层的3D变换

假设您有10个方形图像,它们表示卷轴上的符号。对于每个图像,创建一个
CALayer
谁的内容属性是您的图像之一。然后,对于每个层,您需要应用2个变换:

  • 首先,您需要围绕其X轴旋转每个层(2*PI)/10
  • 然后将一些距离(您需要计算)沿 Z轴
现在将这些层添加到视图的层中。现在,您应该可以看到围绕X轴的“圆柱体”图像

要旋转圆柱体,您需要调整第一个变换-使用
CAAnimation
或使用计时器并通过计时器触发的偏移量调整X轴旋转

我将把它留给您去弄清楚完整的实现细节——但是这里有一些代码可以加载并创建一个初始的“卷轴”

int-imageCount=16;
对于(int i=0;i    int imageCount = 16;

    for (int i = 0; i < imageCount; i++) {
        // Load image from the bundle

        NSString * fileName = [NSString stringWithFormat: @"Image-%d", i];
        NSString * filePath = [[NSBundle mainBundle] pathForResource: fileName ofType: @"jpeg"];

        UIImage * image = [UIImage imageWithContentsOfFile: filePath];

        // Create a layer with the image as content - My image size was 60x60

        CALayer * imageLayer = [CALayer layer];
        imageLayer.bounds = (CGRect){CGPointZero, {60.0, 60.0}};
        imageLayer.contents = (id)image.CGImage;
        imageLayer.position = (CGPoint){CGRectGetMidX(self.view.bounds), CGRectGetMidY(self.view.bounds)};

        // Set the initial image transform - I've hardcoded the translate along the
        // z-axis to 150, but this will vary depending on the number of images
        // and their size - you'll need to do some maths to work it out... sines or 
        // cosines or somesuch
        CGFloat angle = (2.0 * M_PI) / imageCount * i;
        CATransform3D transform = CATransform3DMakeRotation(angle, 1.0, 0.0, 0.0);
        transform = CATransform3DTranslate(transform, 0.0, 0.0, 150.0);  
        imageLayer.transform = transform;

        [self.layers addObject: imageLayer];

        [self.view.layer addSublayer: imageLayer];
    }
}