Tag: uibutton

UIButton标题alignment和多行支持

如何将UIButton的标题设置为左alignment,以及如何在UIButton显示多行文本?

UIButton长按活动

我想模仿长按button,我该怎么做? 我觉得需要一个计时器。 我看到UILongPressGestureRecognizer但我怎么能利用这种types?

如何缩放UIButton的imageView?

我使用[UIButton setImage:forState:]创build了一个名为“button”的UIButton实例。 button.frame大于图像的大小。 现在我想缩小这个button的图像。 我试着改变button.imageView.frame , button.imageView.bounds和button.imageView.contentMode ,但都似乎无效。 任何人都可以帮助我缩放一个UIButton的imageView? 我创build了这样的UIButton : UIButton *button = [[UIButton alloc] init]; [button setImage:image forState:UIControlStateNormal]; 我试图像这样缩放图像: button.imageView.contentMode = UIViewContentModeScaleAspectFit; button.imageView.bounds = CGRectMake(0, 0, 70, 70); 和这个: button.imageView.contentMode = UIViewContentModeScaleAspectFit; button.imageView.frame = CGRectMake(0, 0, 70, 70);

用作左侧或右侧导航栏项目的自定义视图的UIBarButtonItem在iOS 7上未正确alignment

以下代码通过iOS 6完成: UIButton *myButton = nil; myButton = [UIButton buttonWithType:UIButtonTypeCustom]; myButton.bounds = CGRectMake(0,0,44,30); // setup myButton's images, etc. UIBarButtonItem *item = nil; item = [[UIBarButtonItem alloc] initWithCustomView:customButton]; 这是button应该如何alignment: 但是,在iOS 7上,该button看起来偏右或偏左,像素太多: 我如何让我的自定义栏button项目正确alignment?

如何用Swift更改UIButton的字体

我正在尝试使用Swift更改UIButton的字体… myButton.font = UIFont(name: "…", 10) 但是.font被弃用,我不知道如何改变字体,否则。 有什么build议么?

UIButton不听内容模式设置?

firstButton是一个types为Custom的UIButton。 我以编程方式将它们中的三个放在表格的每个单元格中,因此: [firstButton setImage:markImage forState:UIControlStateNormal]; [firstButton setContentMode:UIViewContentModeScaleAspectFit]; [cell.contentView addSubview:firstButton]; 在其他地方,我把它告诉clipToBounds。 我得到的是图像的中心广场,而不是一个纵横比例的渲染。 我已经尝试了很多方法,包括在firstButton.imageView上设置模式属性,这似乎也不起作用。

在UIButton缩放图像到AspectFit?

我想添加一个图像到UIButton,也想缩放我的图像,以适应UIButton(使图像变小)。 请告诉我如何去做。 这是我所尝试过的,但它不起作用: 将图像添加到button并使用setContentMode : [self.itemImageButton setImage:stretchImage forState:UIControlStateNormal]; [self.itemImageButton setContentMode:UIViewContentModeScaleAspectFit]; 制作“拉伸图像”: UIImage *stretchImage = [updatedItem.thumbnail stretchableImageWithLeftCapWidth:0 topCapHeight:0];

iOS 7圆形框架button

iOS应用程序商店有一个蓝色的圆形框架button​​来购买/下载应用程序。 在我的应用程序,你可以下载额外的内容,我想有一个类似的button,只是因为它看起来很熟悉的用户。 如果你不知道,我的意思是:这些button,如“$ 3.99” 这怎么可能?

更改UIButton文本

所以我试图更新UIButton上的文字,当我点击它。 我正在使用以下行来更改文本: calibrationButton.titleLabel.text = @"Calibration"; 我已经validation了文本正在改变,但是当我运行该应用程序,然后单击该button时,它会立即变为“校准”,然后返回到默认值。 任何想法,为什么这可能会发生? 有什么样的刷新function,我需要打电话?

禁用UIButton不褪色或灰色

在我的iPhone应用程序中,我有一个在Interface Builder中创build的UIButton。 我可以成功启用和禁用它像这样在我的代码… sendButton.enabled = YES; 要么 sendButton.enabled = NO; 但是,button的外观总是一样的! 它不褪色或灰色。 如果我尝试点击它,但是按预期启用或禁用。 我错过了什么吗? 它不应该看起来褪色或灰色? 谢谢