【问题标题】:Create Custom alert view or popup创建自定义警报视图或弹出窗口
【发布时间】:2017-11-16 05:43:58
【问题描述】:

我想在应用委托上显示一些警报。当我点击按钮时,警报应该留在那里。如果在 5 分钟内没有采取任何行动,则该警报想要解除。有人请帮我创建一个自定义警报。 常量 CGFloat 字体大小 = 24; // 或者其他。

UILabel* label = [[UILabel alloc] initWithFrame:CGRectZero];
label.backgroundColor = [UIColor clearColor];
label.font = [UIFont fontWithName:@"Helvetica-Bold" size:fontSize];  // Or whatever.
label.text = message;
label.textColor = [UIColor blueColor];  // Or whatever.
[label sizeToFit];

label.center = point;

[self.view addSubview:label];

[UIView animateWithDuration:0.3 delay:1 options:0 animations:^{
    label.alpha = 0;
} completion:^(BOOL finished) {
    label.hidden = YES;
    [label removeFromSuperview];
}];

【问题讨论】:

  • 那是什么问题?
  • 你应该检查 UIPresentationController 类

标签: ios objective-c xcode uiview uialertview


【解决方案1】:

使用https://github.com/shantaramk/Custom-Alert-View

实现这一点毫不费力。只需按照以下步骤操作:

1.将项目目录下的AlertView文件夹往下拉

2。显示警报视图弹出窗口

    func showUpdateProfilePopup(_ message: String) {
         let alertView = AlertView(title: AlertMessage.success, message: message, okButtonText: LocalizedStrings.okay, cancelButtonText: "") { (_, button) in
         if button == .other {
               self.navigationController?.popViewController(animated: true)
           }
        }
       alertView.show(animated: true)
   }

【讨论】:

    猜你喜欢
    • 2012-10-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-31
    • 1970-01-01
    • 2021-12-15
    • 1970-01-01
    相关资源
    最近更新 更多