草庐IT

UiButton

全部标签

ios - 如何在禁用状态下更改 UIButton 图像 alpha?

我有一个带有图像的UIButton,它处于禁用状态,这个图像应该有.3alpha。UIButton*button=[UIButtonbuttonWithType:UIButtonTypeCustom];UIImage*arrowImage=[UIImageimageNamed:@"arrow.png"];[buttonsetImage:arrowImageforState:UIControlStateNormal];//Thearrowshouldbehalftransparenthere[buttonsetImage:arrowImageforState:UIControlState

iphone - 在突出显示时更改 UIButton 边框颜色

我有一个简单的自定义UIButton,我在其中添加了:button.layer.bordercolor=[[UIColorblueColor]CGColor];但是,我想在突出显示按钮时更改.bordercolor。我尝试向按钮的touchDown操作添加一个操作,将.bordercolor更改为红色,但是当用户抬起手指时,它保持红色而不是返回蓝色。有什么想法吗? 最佳答案 您走在正确的轨道上。检查下面的代码,它对此进行了详细说明,但您要做的是将选择器链接到按钮上的不同控制事件。一个用于touchDown将阴影更改为红色,另一个用于

ios - 将按钮图像对齐到 UIButton 的右边缘

有很多关于根据标题文本对齐按钮图像的主题,但我找不到任何关于将图像对齐到按钮右侧的信息。这没有效果:button.imageEdgeInsets=UIEdgeInsetsMake(0,0,0,50);如何右对齐按钮的图像?可以在Storyboard中完成吗? 最佳答案 语义:在View上强制从右到左对我有用 关于ios-将按钮图像对齐到UIButton的右边缘,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.

iphone - iOS:UIButton titleLabel——它能做什么吗?

我想制作一个类型为UIButtonTypeCustom的UIButton(用于形状)。我想使用button.titleLabel分配标题,因为我需要指定字体。下面的代码看起来应该可以工作,但实际上没有——没有标checkout现,句号。UIImage*editButtonImage=[UIImageimageNamed:@"editButton.png"];floatwidth=editButtonImage.size.width;floatheight=editButtonImage.size.height;UIButton*editButton=[UIButtonbuttonWit

ios - UIImageView 内的 UIButton 不响应点击

我有一个ScrollView,它有一个ImageView,ImageView作为subview,ImageView有一个UIButton作为它的subview之一。问题是,我无法点击按钮。我可以看到按钮,但无法点击它。谁能告诉我我搞砸了什么?任何帮助是极大的赞赏!谢谢!代码如下:scrollView=[[UIScrollViewalloc]initWithFrame:[[UIScreenmainScreen]applicationFrame]];imageView=[[UIImageViewalloc]initWithImage:[UIImageimageNamed:@"img.jpg

ios - iOS 7 突出显示时为 UIButton 设置标题颜色

我在viewController中有以下代码,所有outlet和action都正确连接。WHITE和PURPLE是我为其定义常量的UIColors。我还将UIWindow的tintColor设置为PURPLE并向下传播到按钮。-(void)viewDidLoad{[superviewDidLoad];[buttonsetTitleColor:[UIColorwhiteColor]forState:UIControlStateHighlighted];button.backgroundColor=WHITE;button.layer.borderWidth=1.0;button.laye

ios - 带有 GradientLayer 的 UIButton 会遮挡图像并使渐变变暗

我这里有一个UIButton,我希望在其中有一个渐变作为图像下方的背景(具有透明背景的符号),但我面临两个不同的问题。无论我如何尝试添加,CAGradientLayer的第一个似乎都覆盖在图像之上,完全遮盖了图像。其次,渐变本身似乎变暗了很多,就像按钮被禁用了一样,但事实并非如此。这是我的代码:self.backButton=[[UIButtonalloc]initWithFrame:CGRectMake(15,35,28,28)];[backButtonaddTarget:selfaction:@selector(goBack)forControlEvents:UIControlEv

ios - 在 UIButton 中使用 UIBarButtonItem 图标

UIBarButtonItem有多个可用图标。是否可以使用将其标识符设置为“垃圾桶”后出现的图标:用UIButton?没有像设置identifier或style那样直接的方法来做到这一点。 最佳答案 新iOS13支持SFSymbols现在UIImage(systemName:"trash")对于swift4.2(在主线程上调用)extensionUIBarButtonItem.SystemItem{funcimage()->UIImage?{lettempItem=UIBarButtonItem(barButtonSystemIte

ios - 如何在 UIButton 上只添加顶部边框?

我知道如何在iOS7中为按钮添加边框,代码如下:[[myButtonlayer]setBorderColor:[[[UIColorgrayColor]colorWithAlphaComponent:0.5]CGColor]];[[myButtonlayer]setBorderWidth:1];[[myButtonlayer]setCornerRadius:15];但是我怎样才能只添加一个边框呢?我只想添加顶部边框。 最佳答案 UIView*lineView=[[UIViewalloc]initWithFrame:CGRectMake

iphone - UIButton 标题标签不显示

我见过很多类似的问题,但没有人得到我正在寻找的答案。当我使用这段代码制作一个UIButton并将其设置为titleLabel时,UIButton出现,但titleLabel不会出现。UIButton*button=[[UIButtonalloc]initWithFrame:CGRectMake(0,0,50,50)];[buttonsetBackgroundImage:[UIImageimageNamed:@"button.png"]forState:UIControlStateNormal];button.titleLabel.text=@"Title";button.titleLa