Tag: uibutton

具有UISwitchfunction的iPhone UIButton

有没有一种方法来实现开关状态自定义graphics的UISwitch? 或者换个angular度来看,UIButton具有UISwitchfunction?

相当于addTarget的UIButton块:action:forControlEvents:method?

我环顾四周,但无法在互联网上find这个,也没有在苹果文档中的任何地方,所以我猜测它不存在。 但有没有一个iOS4块等效的API来: [button addTarget:self action:@selector(tappy:) forControlEvents:UIControlEventTouchUpInside]; 我想这可以使用一个类来实现,但宁愿不要自己写这个,因为极度的懒惰:) 像这样的东西会很棒: [button handleControlEvent:UIControlEventTouchUpInside withBlock:^ { NSLog(@"I was tapped!"); }];

如何从RGB值正确初始化UIColor?

我正在使用各种颜色的iPhone应用程序。 当用户select特定的颜色button时,我相应地设置了绘画颜色。 我得到了一些颜色,但在大多数情况下我变得白色。 这是我的代码: -(IBAction)colorSelected:(UIButton *)sender { switch (sender.tag) { case 1: self.drawcolor= [UIColor colorWithRed:200 green:191 blue:231 alpha:1]; break; case 2: self.drawcolor= [UIColor colorWithRed:163 green:73 blue:164 alpha:1]; break; case 3: self.drawcolor= [UIColor colorWithRed:112 green:146 blue:76 alpha:1]; break; case 4: self.drawcolor= [UIColor colorWithRed:63 green:72 blue:204 alpha:1]; break; case 5: self.drawcolor= [UIColor colorWithRed:153 green:217 blue:234 alpha:1]; break; […]

在UIImageView上使用Tint颜色

我有我自己的UIButton的子类。 我添加UIImageView并添加图像。 我想用色调来描绘图像,但不起作用。 到目前为止我有: – (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; if (self) { self.backgroundColor = [UIColor clearColor]; self.clipsToBounds = YES; self.circleView = [[UIView alloc]init]; self.circleView.backgroundColor = [UIColor whiteColor]; self.circleView.layer.borderColor = [[Color getGraySeparatorColor]CGColor]; self.circleView.layer.borderWidth = 1; self.circleView.userInteractionEnabled = NO; self.circleView.translatesAutoresizingMaskIntoConstraints = NO; [self addSubview:self.circleView]; self.iconView = [[UIImageView alloc]init]; [self.iconView setContentMode:UIViewContentModeScaleAspectFit]; UIImage * image = [UIImage […]

iPhone SDK的:图像和文字的UIButton可能吗?

我有一个尺寸宽200和高270的button。我想要在同一个button上有文字和图像。 不作为该文本的背景图片。 而不是这个,我想在同一个button上显示高度120和高度图像150的文本。 有人有想法吗? 如果你不明白我的问题,请让我知道。

如何添加投影到UIButton?

我想添加阴影到UIButton。 我试图使用self.layer.shadow *属性。 这些属性在UIView中工作,但它们在UIButton中的行为不同。 我真的很感激,如果我能得到任何指针来绘制阴影。 谢谢! self.layer.cornerRadius = 8.0f; self.layer.masksToBounds = YES; self.layer.borderWidth = 1.0f; self.layer.shadowColor = [UIColor greenColor].CGColor; self.layer.shadowOpacity = 0.8; self.layer.shadowRadius = 12; self.layer.shadowOffset = CGSizeMake(12.0f, 12.0f);

如何在Swift中更改UIButton图像

我正在尝试使用Swift来更改UIButton的图像…我该怎么做 这是OBJ-C code.but我不知道与斯威夫特: [playButton setImage:[UIImage imageNamed:@"play.png"] forState:UIControlStateNormal];

iPhone上的最小智能button尺寸

我正在devise一个iPhone应用程序,它具有相当大的一组屏幕圆angular矩形button。 给定基于手指的触摸屏用户界面,你认为最小的敏感button尺寸是多less? 我需要在视口中尽可能多地安装,而不会过多地影响可用性。 也许有一个苹果推荐的最小尺寸? 现在是33×33,在模拟器上看起来还不错,但我昨天晚上在真正的手机上玩这个应用程序,而且很尴尬 – button感觉太小了。

UIButton不会去iPhone的Aspect Fit

我有一对夫妇UIButtons,在IB他们被设置为Aspect Fit,但由于某种原因,他们总是伸展。 还有什么你必须设置? 我尝试了所有不同的视图模式,没有一个工作,他们都伸展。

在标题中有两行文本的UIButton(numberOfLines = 2)

我试图做一个UIButton在其titleLabel中有两行文字。 这是我正在使用的代码: UIButton *titleButton = [[UIButton alloc] initWithFrame:CGRectMake(15, 10, frame.size.width-100, 100)]; titleButton.titleLabel.font = [UIFont boldSystemFontOfSize:24.0]; [titleButton setTitle:@"This text is very long and should get truncated at the end of the second line" forState:UIControlStateNormal]; titleButton.titleLabel.lineBreakMode = UILineBreakModeTailTruncation; titleButton.titleLabel.numberOfLines = 2; [self addSubview:titleButton]; 当我尝试这个时,文本只出现在一行上。 看来在UIButton.titleLabel实现多行文本的唯一方法是设置numberOfLines=0并使用UILineBreakModeWordWrap 。 但是这并不能保证文本恰好是两行。 然而,使用一个普通的UILabel是可行的: UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, 10, frame.size.width-100, 100)]; […]