草庐IT

UIBUTTON

全部标签

ios - 我怎样才能创建弧形 ios swift

我有一个带有一些按钮的应用程序。我想创建一个如下图所示的弧形按钮我该怎么做?我使用以下代码来实现这一点。button.layer.cornerRadius=button.bounds.size.height和button.layer.cornerRadius=0.5*button.bounds.size.height我也尝试过使用宽度button.layer.cornerRadius=button.bounds.size.width和button.layer.cornerRadius=0.5*button.bounds.size.width我该怎么做?请有人帮我解决这个问题。

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

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

ios - 如何在 Swift 3 中编写带参数的选择器

这个问题在这里已经有了答案:"classnamehasnomemberfunctionname"whenaddingUIButtontarget(4个答案)Attachparametertobutton.addTargetactioninSwift(13个答案)关闭6年前。在Swift2中,这曾经有效(我故意省略了TableView方法)...importFoundationimportUIKitprivateextensionSelector{staticletdidTapButton=#selector(TableVC.buttonTapped(_:))}classTableVC:

ios - 如何让 segue 等待功能在按下按钮时完成?

我有一个swift应用程序,它在一个ViewController上获取一些gps数据,然后将该数据传递给另一个ViewController。我目前的方法涉及一个按钮,用户将在其中输入一些数据,点击此按钮,然后该按钮应执行两个操作,计算gps路线,并执行到下一个ViewController的segue。但是,我似乎无法让segue在进入下一个屏幕之前等待我的计算完成。如果我登陆第二个View然后按返回键,然后再次按按钮,数据将显示在第二个屏幕上,但我似乎无法立即让它工作。我关注了这个问题:SeparateButtonactionandsegueaction而且还是有问题我是一个完全的sw

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?.