- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想做的是将 UILabel
放在 UIButton
之上。UIButton
有一个图像作为背景,结果是我在 UIButton
上看不到正常文本,因此我想放置 UILabel
在它上面。
我的代码是:
NAlertView *customAlert = [[NAlertView alloc] initWithTitle:@"title" message:@"message" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:@"cancel", nil];
[customAlert show];
NAlertView.m:
- (void)layoutSubviews
{
for (id obj in self.subviews) //Search in all sub views
{
if ([obj isKindOfClass:[UIImageView class]]) // Override UIImageView (Background)
{
UIImageView *imageView = obj;
[imageView setImage:[UIImage imageNamed:@"CustomAlertView"]];
[imageView setAlpha:0.7];
[imageView sizeToFit];
}
if ([obj isKindOfClass:[UILabel class]]) // Override UILabel (Title, Text)
{
UILabel *label = (UILabel*)obj;
label.backgroundColor = [UIColor clearColor];
label.textColor = [UIColor whiteColor];
label.shadowColor = [UIColor clearColor];
}
if ([obj isKindOfClass:[UIButton class]]) // Override the UIButton
{
UIButton *button = (UIButton*)obj;
CGRect buttonFrame = button.frame; // Change UIButton size
buttonFrame.size = CGSizeMake(127, 35);
CGFloat newYPos = buttonFrame.origin.y + 9; // Change UIButton position
buttonFrame.origin.y = newYPos;
button.frame = buttonFrame;
[button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[button setTitleColor:[UIColor whiteColor] forState:UIControlStateHighlighted];
switch (button.tag)
{
case kFIRST_BUTTON:
{
[button setImage:[UIImage imageNamed:@"short_button_gold_off.png"] forState:UIControlStateNormal];
[button setImage:[UIImage imageNamed:@"short_button_gold_on.png"] forState:UIControlStateHighlighted];
}
break;
case kSECOND_BUTTON:
{
[button setImage:[UIImage imageNamed:@"short_button_black_off.png"] forState:UIControlStateNormal];
[button setImage:[UIImage imageNamed:@"short_button_black_on.png"] forState:UIControlStateHighlighted];
}
break;
}
}
}
[self updateConstraints];
}
结果:
最佳答案
这意味着您只想在 UIButton 上添加标题?
试试这个 -
[button setBackgroundImage:[UIImage imageNamed:@"short_button_gold_off.png"] forState:UIControlStateNormal];
[button setTitle:@"Title" forState:UIControlStateNormal];
关于ios - 尝试将 UILabel 放在自定义 UIAlertView 中的 UIButton 之上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17336179/
这个问题已经有答案了: iOS How to dismiss UIAlertView with one tap anywhere? (2 个回答) 已关闭10 年前。 嗨,我是 Xcode 新手,ob
我试图在我的 swift 应用程序中显示一个 UIAlertView alert = UIAlertView(title: "", message: "bla",
问题是 iOS 键盘有时不再有反应。所以没有输入是可能的。如果我取消注释 clickedButtonAtIndex 中的第二个 UIAlertView,它工作正常。 原因可能在其他地方?我不知道...
我是 iPhone 开发人员的新人, 我想依次实现2个警报 View ,就像当用户按下删除按钮时,第一个警报 View 会询问你确定要删除吗?有两个按钮是 和否 现在,如果用户按 yes ,则第二个警
我想弄清楚为什么我的应用程序会崩溃。 它在带有 ios5.1 的模拟器中运行的 Xcode 4.4 中运行良好,但是当我切换到 xcode 4.5 和 ios6 时,我得到了 EXC_BAD_ACCE
我的 iOS 应用程序正在使用 Swift 2.0、RMUniversalAlert 版本 0.7 和 UIAlertView+Blocks 版本 0.9 当我在 Xcode 7 中构建它时,出现错误
我遇到了崩溃: *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-
我在主线程上显示 UIAlertView 时遇到问题。我不知道为什么,但它不断崩溃,尽管我在主线程上运行。以下 block 位于后台线程上,但我在主线程上有警报,如下所示: void (^remove
我已将 iPhone 设置为横向模式,但当我尝试显示 UIAlertView 时,它会进入纵向模式。横向模式下如何显示? 最佳答案 在applicationDelegate.m文件的applicati
我使用 UIAlerView 子类创建自定义登录页面。现在,当我单击按钮时,它会打开 UIAlertView 我想根据按下的按钮更改主视图。 但是,由于 UIAlerView 的所有实现都在另一个类中
我弹出一个 UIAlertView 来询问用户是否确实要打开某个 URL。如果他们选择"is",我的应用程序会立即打开 URL 并发送到后台。当用户重新打开我的应用程序(使用多任务处理)时,警报 Vi
有没有办法将 .tag 添加到 UIAlertView 按钮?原因是,我向警报添加了一些动态按钮,这些按钮有时会出现在警报中,有时不会。我认为最好的方法是添加标签。有更好的方法吗? 警报中始终出现的选
我在 ib 中创建了一个自定义 uialertview,带有两个按钮和一个文本字段。然后我以这种方式创建一个 .h 和一个 .m: #import @interface DialogWelcome
看一下下面的代码,问题是AlertView没有显示出来,即使我在调试中看到代码已被执行。 请指教。 非常感谢 埃兰 -(void)displayABC:(id)sender { sta
我正在尝试更改 uialertview 的背景。一切工作正常,除了我添加到 uialert View 的背景图像不会在警报 View 内缩放。所以基本上你只能看到基于当前大小的背景图像的一部分。有什么
在我的应用程序中,我使用验证 key 通过 Wi-Fi 从服务器下载内容。如果许可证 key 错误或 wi-fi 不可用,我需要显示 UIAlert。我已经编写了用于显示警报 View 的男女混合代码
我创建了一个带有两个按钮和一个文本字段的 uialertview,如果文本字段为空,我希望禁用“确定”按钮。我如何获取 uibutton 对象来更改启用状态。 最佳答案 您可以使用从 UIContro
iPhone 应用程序开发人员您好, 我正在开发一个 iPhone 应用程序。该应用程序允许用户将图像上传到我的服务器。我想在alertView中显示上传进度。我需要一些示例代码来说明如何实现带有进度
有没有办法以编程方式隐藏 UIAlertView。我正在我的进度 View 中显示进度 View ,当进度 View = 1.0 时,我想隐藏 UIAlertView。 最佳答案 您可以做的是观察(使
这个问题已经有答案了: 已关闭10 年前。 Possible Duplicate: Is it possible to lay out 2 buttons vertically on UIAlertV
我是一名优秀的程序员,十分优秀!