【问题标题】:How to customize UIAlert View..?如何自定义 UIAlert 视图..?
【发布时间】:2013-02-05 10:06:31
【问题描述】:

我通过添加图像来自定义UIViews,使其看起来像单选按钮或复选框,但对于我的规范,我想让UIAlertView 看起来像这样...

谁能建议如何做到这一点? 谢谢!

【问题讨论】:

  • 您可以自定义警报视图但 iTunes 拒绝您的应用...
  • @Vishal 你确定...?
  • 那是糟糕的用户界面。您应该改用 UIActionSheet。
  • 是的,我确定...你可以用谷歌搜索...
  • @zoul 归功于我们的设计师 :)

标签: iphone ios cocoa-touch uilabel uialertview


【解决方案1】:

您可以设计自定义视图,并可以使用此代码将动画作为警报视图赋予它

    -(void)initialDelayEnded 
{

    alert_upload.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.001, 0.001);
    alert_upload.alpha = 1.0;
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:1/1.5];
    [UIView setAnimationDelegate:self];
    [UIView setAnimationDidStopSelector:@selector(bounce1AnimationStopped)];
    alert_upload.transform = CGAffineTransformScale(CGAffineTransformIdentity, 1.1, 1.1);
    [UIView commitAnimations];
}

- (void)bounce1AnimationStopped {
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:1.5/2];
    [UIView setAnimationDelegate:self];
    [UIView setAnimationDidStopSelector:@selector(bounce2AnimationStopped)];
    alert_upload.transform = CGAffineTransformScale(CGAffineTransformIdentity, 0.9, 0.9);
    [UIView commitAnimations];
}

- (void)bounce2AnimationStopped {
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:1.5/2];
    alert_upload.transform = CGAffineTransformIdentity;
    [UIView commitAnimations];


}

alert_upload 是 UIView。

【讨论】:

    【解决方案2】:

    many previous questions about this topic,其中一个链接this component,可让您创建自定义警报和操作表。可能是一个不错的开始方式。

    【讨论】:

    • @NikitaP UIAlertView 类旨在按原样使用,不支持子类化。此类的视图层次结构是私有的,不得修改。
    • @MilKyWaY:是的,但谁要求你继承它。只需在它上面添加subview。这是完全可以接受的。我已经接受了一个应用程序(2013 年 1 月 20 日),其中我在 alertview 上添加了子视图来修改它
    • @NikitaP 没有人要求你继承它!只是指出来让你知道如果你不是。添加子视图不是一个坏主意..
    • @NikitaP 可以分享一个通过添加子视图自定义的alertview的截图吗?
    • 请注意,GitHub 上的链接库没有子类化 UIAlertViewUIActionSheet,它是一个重新实现,因此它在 App Store 上应该是完全安全的。
    【解决方案3】:

    您可以创建自己的自定义警报视图,除非用户交互,否则 Apple 不会拒绝它。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-06-23
      • 2013-04-25
      相关资源
      最近更新 更多