Tag: uibutton

UIButton与图片和文字

我试图做一个button,基本上模仿在iphone的主屏幕上看到的button – 它有一个垂直放置在一些文本上方的图片,都是button的一部分,并突出显示时适当(暗淡,点击等)行为。 我已经尝试将图片或文本放入自己的框架中,但不起作用,因为在新框架中的任何一个都不会与button的其余部分变暗。 使用背景图像属性不起作用,因为我想要图像上方的图像 – 文本背后的区域应该是透明的。 我真的更喜欢编程解决scheme,而不是进入和编辑我的所有照片。

如何在UITableView Cell中以编程方式创buildn个UIButton?

我想创build一个具有n个button的UITableView取决于后端JSON数据。 我已经附加了一个图像,我知道如何在UITableViewCell上创buildUIButtons,但我不知道如何将它们正确放置在UITableViewCell 。 用于UITableViewCell UIButton UIButton *continuebtn = [[UIButton alloc]initWithFrame:CGRectMake(10, 100, view1.frame.size.width-20, 40)]; [continuebtn setBackgroundColor:[UIColor grayColor]]; [continuebtn setTitle:@"Continue" forState:UIControlStateNormal]; continuebtn.layer.cornerRadius = 10; continuebtn.layer.borderWidth =1.0; continuebtn.layer.borderColor = [UIColor blackColor].CGColor; [continuebtn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; 如何在UITableViewCell上放置'n'个UIButton ? UIButton宽度取决于其文本内容

如何在iOS中连接两个button(点)?

我想做一个项目,我必须触摸一个点,并连接到另一个点,并连接到另一个点后。 当我连接一个点与另一个点时,线会在它们之间创build。 其实当我点击/触摸一个点线会显示,当我触摸第二个点时,线将创build两个点之间。 我无法做到这一点,我试图在网上search,但无法find解决scheme。 这是我的需要喜欢这一个https://play.google.com/store/apps/details?id=zok.android.dots&hl=en 我认为这是由UIGesture Recogniser完成的? 还是这是别的? 我怎么能做到这一点? 任何意见或build议的专家将非常欢迎。

UIView内的UIButton Target Action

我有一个自定义的UIView我在其中创build了一个UIButton 。 在这个视图里面,我有这样的代码: func setupViews() { menuControlButton.addTarget(self, action: "toggleButton:", forControlEvents: .TouchUpInside) } func toggleButton(sender: MenuControlButton!) { let isActive = sender.toggleActive() // switches button image and returns whether active or not after NSUserDefaults.standardUserDefaults().setBool(isActive, forKey: sender.title) someOtherViewController.reloadCalendar() } 这是一个不好的做法吗? 特别是因为我通过自定义UIView调用另一个控制器的function。 我应该这样做,所以这些方法在ViewController? 还是有更好的方法来做到这一点?

如何绘制一个三angular形的UIButton

我真的挖了IFTTT右下angular的button,如图(右下)所示。 我尝试过使用CGContext和UIBezierPath来匹配效果,但是我根本不知道如何正确使用它。 有没有人有一些想法/代码如何做到这一点? 谢谢!

UIButton分组button

我正在尝试创build一个完全像这样的button: 我将如何做到这一点? 有人可以告诉我的代码? 有没有办法像这样“分组”UIButtons?

UITableViewCell中的UIButton

我有一个在UITableViewCell的子类myCustomCell类2 UIButtons。 黑色轮廓是由“ cellForRowAtIndex ”返回的单元格 (UITableViewCell *)。 这个单元格包含' myCustomCell '作为子视图。 ' myCustomCell '有两个UIButtons和以下属性: backgroundcolor = clearColor opaque = NO 单击单元格中除了两个红色框(UIbutton)之外的任何地方,我想' didSelectRowAtIndexPath '被触发。 但是,如果用户点击UIButton,只需要触发目标的select器,而不是“didSelectRowAtIndexPath”。 我怎样才能做到这一点?

将UIButton的背景颜色从WhiteColoranimation到RedColor

我正在试图制作一种颜色脉冲效果animationUIButton背景颜色,使其从颜色(WhiteColor)不断地改变到另一个(RedColor)。 我试图使用CABasicAnimation改变不透明度,但我不能让它与颜色也工作。 CABasicAnimation *theAnimation; theAnimation=[CABasicAnimation animationWithKeyPath:@"opacity"]; theAnimation.duration=1.0; theAnimation.repeatCount=HUGE_VALF; theAnimation.autoreverses=YES; theAnimation.fromValue=[NSNumber numberWithFloat:1.0]; theAnimation.toValue=[NSNumber numberWithFloat:0.0]; [BigButton.layer addAnimation:theAnimation forKey:@"animateOpacity"]; 每一个build议,将不胜感激。 谢谢

以编程方式添加一个button的视图

我想像下面这样以编程方式添加一个视图和一个button。 问题在于button在点击时不起作用。 我的意思是既没有突出显示或调用select器。 原因是我想实现一个logging(声音文件)的列表行。 列表行应该是可选的下钻,并有一个播放button。 所以我得到了一个RecordingView子类化UIView ,它自己从构造函数中添加一个使用目标的button。 看下面的代码。 如果有人有更好的方法来做到这一点,也可以解决。 @implementation MyViewController – (IBAction) myAction { RecordingView *recordingView = [[RecordingView alloc] initWithFrame:CGRectMake(30, 400, 130, 50)withTarget:self]; [recordingView setUserInteractionEnabled:YES]; [[self view] addSubview:recordingView]; } @implementation RecordingView – (id)initWithFrame:(CGRect)frame withTarget:(id) target { self = [super initWithFrame:frame]; UIButton *playButton = [[UIButton alloc] initWithFrame:CGRectMake(185, 5, 80, 40)]; [playButton setTitle:@"Play" forState:UIControlStateNormal]; [playButton setTitleColor:[UIColor […]

在iOS中设置两种不同颜色的button标题

我想用两种颜色在Button上设置标题。 它可能与下面给出的图像相同吗? 任何帮助将不胜感激。 提前致谢。