草庐IT

uibuttons

全部标签

ios - Xcode 中的 Control-drag 提供了 socket ,但没有对 UIButton 的操作。为什么?

在我正在构建的应用程序中,我有一个导航Controller和一个作为subview连接的ViewController(这个词正确吗?)。我添加了一个UIButton并尝试按住Control键将其拖到我的ViewController类文件中,但它只给我Outlet和Outlet集合作为我的选项,而不是Action。ScreenshotofwhatI'mseeing这是一个非常简单的应用程序,我已经尝试删除我的Pod作为修复,但到目前为止运气不好。我也尝试过手动编写函数并尝试将其连接回按钮,但无济于事。拖回工作区中的按钮不起作用,并且在我测试应用程序时该功能未触发。这是我试过的代码:@IB

ios - 在制作自定义 UIButton 时以 NSException 类型的未捕获异常终止

我想制作一个自定义按钮并在自定义按钮类内的选择器内提供输入,但它给我一个错误消息。我该如何修复它我在Playground上测试它,因为当我运行到模拟器时应用程序崩溃了。这是Playground上出现的错误terminatingwithuncaughtexceptionoftypeNSException这是我在Playground上的代码classcustomButton:UIButton{lettitleName:StringletselectorName:Stringinit(titleName:String,selectorName:String){self.titleName=t

uiviewcontroller - 在自定义单元格中点击 UIButton 后显示新的 ViewController

嘿嘿!我想显示一个带有Action的ViewController(自定义单元格中UIButton的tappedInside)。在这种情况下,我不能仅通过控制从自定义单元格中的UIButton拖动到NavigationController(嵌入了ViewController)。我如何才能意识到tableview一行中按钮(在自定义单元格中)上的“tappedInside”会显示一个新的ViewController?谢谢! 最佳答案 您可以在单击具有委托(delegate)的单元格时触发:functableView(tableView:

ios - 在 AppDelegate 中设置 UIButton 外观时如何更改 SafariViewController 中导航栏的色调

当在AppDelegate中设置UIButton.appearance()时,我正在尝试更改SFSafariViewController中导航栏的色调.例如:AppDelegatefuncapplication(_application:UIApplication,didFinishLaunchingWithOptionslaunchOptions:[UIApplicationLaunchOptionsKey:Any]?)->Bool{//HereistheglobalsettingthatIwanttooverrideintheSafariViewControllerUIButton

ios - 如何为 UIButton 保留图像的 tintColor?

我创建了一个自定义类CircularButton,我可以在其中设置自定义image、backgroundColor、tintColor图像和inset到按钮的边缘。它工作正常,除了tintColor。我希望能够设置tintColor,但如果我不提供,它应该保留图像的原始tintColor(呈现为模板图像)。openclassCircularButton:UIButton{publicinit(width:CGFloat,backgroundColor:UIColor?=nil,tintColor:UIColor?=nil,image:UIImage?=nil,contentMode:C

ios - 如何为 1px 宽的 UIButton 添加黑色轮廓?

我是xcode的新手,想为1px宽的UIButton添加黑色轮廓。我在Xcode中通过检查器搜索了UIButton但找不到设置。我已经阅读了关于UIButton的文档,但它似乎没有这个特定的功能。是否可以为UIButton添加彩色轮廓? 最佳答案 在viewDidLoad()中我输入:self.buttonName.layer.borderWidth=1self.buttonName.layer.borderColor=UIColor.whiteColor().CGColor 关于ios

ios - 使用 UIButton 在三种状态之间切换

我有一个UIButton,我想在按下它时切换它的标题和颜色。该按钮应具有三种状态:每日、每月和每年。现在我有这个看起来不太优雅的解决方案:ifsender.currentTitle=="Daily"{sender.setTitle("Monthly",for:.normal)sender.setTitleColor(UIColor(hex:"FB967F"),for:.normal)}elseifsender.currentTitle=="Monthly"{sender.setTitle("Yearly",for:.normal)sender.setTitleColor(UIColor

Swift 3 可拖动的 UIButton

抱歉,我仍在学习Swift的基础知识。我试图在拖动按钮时移动它,这听起来很简单。我不知道如何将发件人信息传递给拖动功能,以便我可以将其与正在拖动的按钮相关联。我创建了多个只有文本的单字按钮,并为每个按钮附加了一个平移手势识别器:letpan=UIPanGestureRecognizer(target:self,action:#selector(panButton(_:)))letword=UIButton(type:.system)word.addGestureRecognizer(pan)我已经创建了这个函数来在按钮被移动时触发:funcpanButton(sender:UIPanG

ios - 如何保持 UIButton 突出显示直到第二次触摸?

我想将按钮保持在突出显示状态图像直到第二次触摸以将其释放到正常状态。我试过dispatch_async方法,但是再点击一次就无法恢复到正常状态。(我在Swift中编码,所以performSelector:WithObject方法也不起作用。) 最佳答案 我将使用选中状态而不是突出显示。UIButton已有该属性,因此您无需创建任何其他属性。button.setImage(image,forState:UIControlState.Normal)button.setImage(selectedImage,forState:UICont

ios - UIButton 作为 UINavigationItem titleView

我正在尝试放置一个UIButton作为我的UINavigationItem的titleView。这是我的代码,但它不起作用。标题完全空白。overridefuncviewDidLoad(){super.viewDidLoad()lettitleButton=UIButton()titleButton.titleLabel?.font=UIFont(name:"HelveticaNeue-Medium",size:16)titleButton.titleLabel?.textAlignment=NSTextAlignment.Center;titleButton.titleLabel?.