【问题标题】:How to drag a image from one button to another button in iPhone?如何将图像从一个按钮拖到 iPhone 中的另一个按钮?
【发布时间】:2012-09-24 13:04:21
【问题描述】:

目前我正在使用 iPhone 应用程序,使用两个按钮,然后我设置了 button1 和 button2 的图像,然后我尝试将图像从 button1 拖到 button2,可以这样做吗?请帮帮我

提前致谢

 button1 = [UIButton buttonWithType:UIButtonTypeCustom];
[button1 setImage:[UIImage imageNamed:@"hearta.png"] forState:UIControlStateNormal];
button1.frame=CGRectMake(10, 60, 50, 50);
[button1 addTarget:self action:@selector(Button1Method) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button1];  

button2 = [UIButton buttonWithType:UIButtonTypeCustom];
[button2 setImage:[UIImage imageNamed:@"club4.png"] forState:UIControlStateNormal];
button2.frame=CGRectMake(61, 60, 50, 50);
[button2 addTarget:self action:@selector(Button2Method) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button2]

【问题讨论】:

    标签: iphone ios image button drag


    【解决方案1】:

    您可以从this demo项目获得参考。

    很好看。

    还有一个link is here

    【讨论】:

      【解决方案2】:

      有不止一种方法可以做到这一点......

      1. 您可以在按钮 1 的单击事件或操作上创建 UIImageView 并使用动画将该图像拖动到按钮 2 使 imageview.image 等于按钮 2 的图像,并排制作原始图像视图为 nil,以便您可以显示它消失在 button2 中。

      2. 另外,你可以直接使用UIImageViews而不是按钮,并在那里的点击方法上制作和动画效果。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-01-11
        • 1970-01-01
        • 2020-02-20
        • 1970-01-01
        相关资源
        最近更新 更多