草庐IT

UiButton

全部标签

ios - 如何在 UITableViewCell 中为 UIButton 设置 Action

我有XIB文件TimerCell.xib和UITableViewCell。在cellForRowAtIndexPath的其他类中,我初始化了这个UITableViewCell:staticNSString*CellIdentifier=@"cellTimer";TimerCell*cell=[tableViewdequeueReusableCellWithIdentifier:CellIdentifier];if(cell==nil){//cell=[[TimerCellalloc]initWithStyle:UITableViewCellStyleDefaultreuseIdenti

ios - UIButton 在 iOS7 中的 UIPageViewController 中的 ViewController 中没有突出显示

我在ViewController中有一个UIButton,它嵌入在UIPageViewController中。页面ViewController处于滚动模式(所以没有手势)。当我触摸按钮时,将调用操作方法,但按钮没有发生可见状态更改(突出显示状态)。这意味着按钮看起来没有被触及。仅在iOS7中观察到。有什么解决办法吗?案例1:在NormalViewController中,带有和不带有Tap的Button的行为案例2:在PageViewController的viewController之一中,使用和不使用Tap时Button的行为 最佳答案

iphone - 在 View Controller 的宽度上水平均匀分布 UIButton 的最简单方法?

我看了很多答案,它们看起来都很复杂!最近我在看thisanswer尽管我不想将我的按钮放在View中。我有6个尺寸相同的UIButton。我想在我的RootViewController的整个宽度和底部将它们水平均匀地隔开。|||||[b1][b2][b3][b4][b5][b6]|________________________________________以编程方式实现此目的的最简单方法是什么? 最佳答案 我认为这比已接受答案上的链接更简单。好的,首先让我们创建一些按钮:UIButton*button1=[UIButtonbut

ios - 使用自动布局时如何更改默认的 UIButton 填充

在iOS6中使用自动布局时,UIButton的固有内容大小似乎包括按钮文本周围大约10像素的填充。有没有办法控制这个填充值?例如,我希望能够做这样的事情,将每边的填充设置为5px:[buttonsetPadding:UIEdgeInsetsMake(5,5,5,5)];我已经尝试设置contentEdgeInsets、titleEdgeInsets和imageEdgeInsets,但均无济于事。奇怪的是,在contentEdgeInsets中指定一个负的左值或右值似乎有一些效果,但不是顶部或底部。无论哪种方式,我都希望能够将实际填充值指定为正数,而不是对表示为负数的默认值进行调整。有人

objective-c - iOS - 双击 uibutton

我有一个按钮,我正在测试它的点击,点击一次它会改变背景颜色,点击两次另一种颜色,点击三次另一种颜色。代码是:-(IBAction)button{UITapGestureRecognizer*tapOnce=[[UITapGestureRecognizeralloc]initWithTarget:selfaction:@selector(tapOnce:)];UITapGestureRecognizer*tapTwice=[[UITapGestureRecognizeralloc]initWithTarget:selfaction:@selector(tapTwice:)];UITapG

objective-c - 子类化 UIButton 以处理点击

按照目前的情况,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visitthehelpcenter指导。关闭9年前。我正在尝试对UIButton进行子类化以创建一个“更智能”的按钮,其中包含用于处理点击事件的逻辑。实现此目标的最佳方法是什么?我只需要重写一个onClick方法吗?或者我是否需要注册一个事件处理程序(如果需要,应该在哪里注册,因为有很多方法可以初始化UIButton?)

ios - 如何在两个 PNG 图像之间为 UIButton 设置动画?

我有两个PNG文件想用作按钮。如何通过在这两个图像之间快速切换来为UIButton设置动画? 最佳答案 您可以使用按钮的imageView的animationImages属性:myButton.imageView.animationImages=[NSArrayarrayWithObjects:[UIImageimageNamed:@"image1.png"],[UIImageimageNamed:@"image2.png"],nil];myButton.imageView.animationDuration=0.5;//whate

ios - 如果将 UIView 添加为 subview ,则 UIButton 目标不起作用

我有一个UIButton。它有两个subview。然后我打电话:[createButtonaddTarget:selfaction:@selector(openComposer)forControlEvents:UIControlEventTouchUpInside];如果我点击UIButton中未被覆盖但它的subview之一的部分,它可以正常工作。但是,如果我改为点击其中一个subview,它不会触发操作。在两个subview上,我都将.userInteractionEnabled设置为YES。两个subview都是带有frame和backgroundColor的普通UIViews

ios - 触摸时自定义 UIButton 不突出显示

我有一个创建自定义UIButton的方法,允许我使用QuartzCore更改按钮的颜色。但是按钮在触摸时不会突出显示。-(UIButton*)makeHeaderButton{UIButton*button=[UIButtonbuttonWithType:UIButtonTypeCustom];UIFont*textFont=[UIFontboldSystemFontOfSize:12];UIColor*textColor=[UIColorcolorWithRed:80/255.0green:109/255.0blue:145/255.0alpha:1.0];UIColor*backg

iphone - UILongPressGestureRecognizer 关闭 UIButton 高亮显示

我将UILongPressGestureRecognizer添加到UIButton。当我按下UIButton时,它会按预期突出显示。但是,当调用UILongPressGestureRecognizer选择器时,突出显示将关闭。UILongPressGestureRecognizer*longpressGesture=[[UILongPressGestureRecognizeralloc]initWithTarget:selfaction:@selector(longPressHandler:)];longpressGesture.minimumPressDuration=5;[long