草庐IT

uibuttons

全部标签

ios - 在 UIButton 上左对齐图像和居中文本

我看过关于右对齐的帖子,但我无法让左对齐工作。我希望按钮占据屏幕的宽度,左侧是图像,中间是标题/文本。这不起作用(至少可靠):button.titleLabel.textAlignment=UITextAlignmentCenter;[buttonsetImageEdgeInsets:UIEdgeInsetsMake(0,-60.0,0,0)];button.frame=CGRectMake((self.view.frame.size.width-w)/2,self.view.frame.size.height-140.0,self.view.frame.size.width-10.0

iphone - UIButton 标题对齐和多行支持

如何将UIButton的标题设置为左对齐,以及如何在UIButton中显示多行文本? 最佳答案 这也是在代码中执行UIButton对齐的代码:-[myButtonsetContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft]; 关于iphone-UIButton标题对齐和多行支持,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.co

iphone - 如何向标准 UIButton 添加角标(Badge)?

关闭。这个问题需要更多focused.它目前不接受答案。想改进这个问题吗?更新问题,使其只关注一个问题editingthispost.关闭8年前。Improvethisquestion是否可以将标准外观的角标(Badge)添加到标准UIButton?如果半本地不支持,实现此目的的最简单方法是什么?示例图片:

ios - UIButton 不听内容模式设置?

firstButton是自定义类型的UIButton。我以编程方式将其中三个放在表格的每个单元格中,因此:[firstButtonsetImage:markImageforState:UIControlStateNormal];[firstButtonsetContentMode:UIViewContentModeScaleAspectFit];[cell.contentViewaddSubview:firstButton];在其他地方,我告诉它clipToBounds。我得到的是图像中心正方形的裁剪,而不是它的纵横比渲染。我已经尝试了很多方法,包括在firstButton.image

ios - 触摸后保持 UIButton 被选中

在我的用户点击一个按钮后,我希望该按钮在我执行网络操作期间保持按下状态。当网络操作完成后,我想让按钮恢复到默认状态。我试过在按下按钮后立即调用-[UIButtonsetSelected:YES](在我的网络之后相应调用-[UIButtonsetSelected:NO]op完成)但它似乎没有做任何事情。如果我调用setHighlighted:也是一样。我想我可以尝试换掉背景图像以表示网络操作期间的选定状态,但这似乎是一种hack。有更好的建议吗?这是我的代码:-(IBAction)checkInButtonPushed{self.checkInButton.enabled=NO;self

ios - 是否可以以编程方式更新 UIButton 标题/文本?

我有一个UIButton,按下它会弹出一个新View,用户可以在其中更改一些设置。当View被关闭时,我想更新UIButton的标题/文本以反射(reflect)新状态。我在打电话:[myButtonsetTitle:@"myTitle"forState:UIControlStateNormal];[myButtonsetTitle:@"myTitle"forState:UIControlStateApplication];[myButtonsetTitle:@"myTitle"forState:UIControlStateHighlighted];[myButtonsetTitle:

ios - UIButton 不会去 iPhone 中的 Aspect Fit

我有几个UIButton,在IB中它们被设置为AspectFit,但由于某种原因它们总是拉伸(stretch)。还有什么你必须设置的吗?我尝试了所有不同的View模式,但没有一个起作用,它们都被拉伸(stretch)了。 最佳答案 解决方案是在UIButton的imageView属性上设置contentMode。我相信必须使用自定义类型创建UIButton才能使其正常工作(否则将为此属性返回nil)。 关于ios-UIButton不会去iPhone中的AspectFit,我们在Stack

ios - iPhone UIButton - 图像位置

我有一个UIButton文本“探索应用程序”和UIImage(>)在InterfaceBuilder中,它看起来像:[(>)Exploretheapp]但我需要将这个UIImage放在文本之后:[Exploretheapp(>)]如何将UIImage移动到右侧? 最佳答案 我的解决方案很简单[buttonsizeToFit];button.titleEdgeInsets=UIEdgeInsetsMake(0,-button.imageView.frame.size.width,0,button.imageView.frame.siz

ios - 是否可以调整 UIButton 的 titleLabel 的 x,y 位置?

是否可以调整UIButton的titleLabel的x,y位置?这是我的代码:UIButton*btn=[UIButtonbuttonWithType:UIButtonTypeRoundedRect];[btnsetFrame:CGRectMake(0.0f,0.0f,100.0f,100.0f)];[btnsetTitle:[NSStringstringWithFormat:@"Button%d",i+1]forState:UIControlStateNormal];[btnaddTarget:selfaction:@selector(buttonPressed:)forContro

ios - 禁用的 UIButton 不褪色或灰色

在我的iPhone应用程序中,我有一个在InterfaceBuilder中创建的UIButton。我可以在我的代码中像这样成功启用和禁用它......sendButton.enabled=YES;或sendButton.enabled=NO;但是,按钮的视觉外观总是一样的!它没有褪色或变灰。如果我尝试单击它,它会按预期启用或禁用。我错过了什么吗?它不应该看起来褪色或灰色吗? 最佳答案 您可以使用以下代码:sendButton.enabled=YES;sendButton.alpha=1.0;orsendButton.enabled=