草庐IT

uibuttons

全部标签

ios - UIButton 事件跟踪 Google Analytics(Swift)

我想使用GoogleAnalytics跟踪用户点击UIButton时的事件。我有下面的代码,但显示错误。我哪里错了?谢谢代码:@IBActionfuncstartGame1(sender:AnyObject){vartracker=GAI.sharedInstance().defaultTrackertracker.send(GAIDictionaryBuilder.createEventWithCategory("Game1",action:"StartPressed",label:"StartTimerOne",value:nil).build())}错误:Cannotinvoke

swift - 你如何设置带有图像的 UIButton 的高度和宽度

这让我抓狂。我到处都看过,但无法弄清楚。检查一下...letfindMeButton=UIButton(type:UIButtonType.System)findMeButton.translatesAutoresizingMaskIntoConstraints=falsefindMeButton.setImage(UIImage(named:"locateMe"),forState:UIControlState.Normal)findMeButton.addTarget(self,action:#selector(MapViewController.findUserLocation(

swift - 你如何设置带有图像的 UIButton 的高度和宽度

这让我抓狂。我到处都看过,但无法弄清楚。检查一下...letfindMeButton=UIButton(type:UIButtonType.System)findMeButton.translatesAutoresizingMaskIntoConstraints=falsefindMeButton.setImage(UIImage(named:"locateMe"),forState:UIControlState.Normal)findMeButton.addTarget(self,action:#selector(MapViewController.findUserLocation(

swift - 添加 UIButton 目标时为 "classname has no member functionname"

这里是Swift和iOS开发的super新手。我正在关注thistutorial关于在单个ViewiOS应用程序中实现自定义控件。这是一个Swift2教程,但到目前为止,我可以将所有内容转换为3(我使用XCode8Beta)。我有一个自定义类RatingControl,连接到Storyboard中的一个View。在类的构造函数中,我创建了一个按钮:letbutton=UIButton(frame:CGRect(x:0,y:0,width:44,height:44))button.backgroundColor=UIColor.red()然后,我尝试为按钮分配一个Action。教程说我应

swift - 添加 UIButton 目标时为 "classname has no member functionname"

这里是Swift和iOS开发的super新手。我正在关注thistutorial关于在单个ViewiOS应用程序中实现自定义控件。这是一个Swift2教程,但到目前为止,我可以将所有内容转换为3(我使用XCode8Beta)。我有一个自定义类RatingControl,连接到Storyboard中的一个View。在类的构造函数中,我创建了一个按钮:letbutton=UIButton(frame:CGRect(x:0,y:0,width:44,height:44))button.backgroundColor=UIColor.red()然后,我尝试为按钮分配一个Action。教程说我应

ios - 突出显示/选定状态问题的 UIButton 背景颜色

我有一个UIButton并且我创建了一个扩展来为不同的状态添加背景颜色。我正在使用以下代码:extensionUIButton{funcsetBackgroundColor(color:UIColor,forState:UIControlState){UIGraphicsBeginImageContext(CGSize(width:1,height:1))CGContextSetFillColorWithColor(UIGraphicsGetCurrentContext(),color.CGColor)CGContextFillRect(UIGraphicsGetCurrentCont

ios - 突出显示/选定状态问题的 UIButton 背景颜色

我有一个UIButton并且我创建了一个扩展来为不同的状态添加背景颜色。我正在使用以下代码:extensionUIButton{funcsetBackgroundColor(color:UIColor,forState:UIControlState){UIGraphicsBeginImageContext(CGSize(width:1,height:1))CGContextSetFillColorWithColor(UIGraphicsGetCurrentContext(),color.CGColor)CGContextFillRect(UIGraphicsGetCurrentCont

ios - 将 UILabel 的某些部分变成 UIButton?

这个问题在这里已经有了答案:Createtap-able"links"intheNSAttributedStringofaUILabel?(37个答案)关闭5年前。我有一个属性字符串UILabel,我能够为文本的某些部分着色lettext="Whydid\(event)give\(event2)a5starsreview?Detailshere."letlinkTextWithColor="Whydid"letrange=(textasNSString).rangeOfString(linkTextWithColor)letattributedString=NSMutableAttri

ios - 将 UILabel 的某些部分变成 UIButton?

这个问题在这里已经有了答案:Createtap-able"links"intheNSAttributedStringofaUILabel?(37个答案)关闭5年前。我有一个属性字符串UILabel,我能够为文本的某些部分着色lettext="Whydid\(event)give\(event2)a5starsreview?Detailshere."letlinkTextWithColor="Whydid"letrange=(textasNSString).rangeOfString(linkTextWithColor)letattributedString=NSMutableAttri

ios - 如何循环遍历我的 Swift View 中的所有 UIButton?

我如何在Swift的View中循环遍历所有UIButtons?我想将所有标题设置为"",但我在Swift中的for循环出错。forbtnsinself.viewas[UIButton]{//setthetitleto""} 最佳答案 这段代码应该可以工作:forviewinself.view.subviewsas[UIView]{ifletbtn=viewas?UIButton{btn.setTitleForAllStates("")}}您需要遍历subViews数组。 关于ios-如何