【问题标题】:Fading in and out UIButton in view在视图中淡入淡出 UIButton
【发布时间】:2011-12-24 06:07:21
【问题描述】:

在我的 iPad 应用程序中,我需要显示出版物的封面图片。用户可以点击封面以获取详细信息。

我考虑过将 UIButtons 渲染为自定义按钮,并将封面图像作为背景图像。是否可以淡入淡出 UIButtons?用户可以选择要显示的出版物的类别,然后他更改我想要淡出一些出版物的类别。

【问题讨论】:

    标签: ios ipad uibutton


    【解决方案1】:

    如果您希望按钮在动画时响应事件,请确保启用用户交互

    [UIView
            animateWithDuration:5.0
            delay:0.0
            options:UIViewAnimationOptionAllowUserInteraction
            animations:^{ button.alpha = 0.0; }
            completion:nil];
    

    【讨论】:

      【解决方案2】:

      任何UIView(包括UIButton)的alpha 属性都可以使用基于块的动画方法进行动画处理:

      [UIView animateWithDuration:0.25 animations:^{myButton.alpha = 0.0;}];
      

      这将使您的按钮在 0.25 秒内淡出。将alpha 设置为 1.0 以再次淡入。

      【讨论】:

      • 好的。感谢那!这意味着我需要为每个Button创建一个UIview,然后将UIButton嵌入到UIView中?
      • 不,myButton 是本示例中的按钮。这是UIView的类方法,不需要调用实例。
      猜你喜欢
      • 1970-01-01
      • 2013-05-24
      • 2013-05-23
      • 2016-02-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多