草庐IT

button-text

全部标签

iOS/swift : Can't assign optional String to UILabel text property

UILabel有一个文本属性,它是一个可选的字符串,但它的行为似乎像一个隐式展开的可选。为什么我不能给它分配另一个可选字符串?谢谢。@IBOutletweakvartweetContent:UILabel!...varunopt:String="foo"varopt:String?="bar"varopt2:String?opt2=opt//Worksfinecell.tweetContent.text?=unopt//Worksfinecell.tweetContent.text?=opt//Compileerror:Valueofoptionaltype'String?'notun

android - Widget.AppCompat.Button colorButtonNormal 显示灰色

我有values:styles.xml有:@color/my_color@android:color/white和values-v21:styles.xml与:@color/my_color@android:color/white应用风格与@style/AppTheme.Button但颜色显示为灰色而不是@color/my_color 最佳答案 要自定义一个按钮,只需将android:theme="@style/AppTheme.Button"设置为您的按钮。按照你在问题中所做的那样定义你的风格@color/my_color[编辑]

android - Widget.AppCompat.Button colorButtonNormal 显示灰色

我有values:styles.xml有:@color/my_color@android:color/white和values-v21:styles.xml与:@color/my_color@android:color/white应用风格与@style/AppTheme.Button但颜色显示为灰色而不是@color/my_color 最佳答案 要自定义一个按钮,只需将android:theme="@style/AppTheme.Button"设置为您的按钮。按照你在问题中所做的那样定义你的风格@color/my_color[编辑]

swift - Button.isHighlighted 时如何更改边框颜色

我想知道如何在我的UIButton周围设置边框,以便在单击或突出显示时更改不透明度及其中的文本。我的逻辑告诉我,它应该是这样的......但它似乎不起作用://BTNSTYLINGbtnstd.layer.cornerRadius=5btnstd.layer.borderWidth=1.5btnstd.layer.borderColor=UIColor.white.cgColor//Changebordercolorwhenhighlightedif(btnstd.isHighlighted){btnstd.layer.borderColor=UIColor(white:1,alpha

iOS swift : Update navigation button with "Back" text

在Stackoverflow上,很少有人提出和回答过类似的问题。但是没有一个解决方案符合我的要求。我正在使用Swift3进行IOS移动应用程序开发,并使用导航Controller来管理导航。我使用以下代码为所有页面赋予了标题。self.title="Title"当我移至下一页时,它会显示带有较早页面标题的后退按钮。对于某些页面,标题很长,它扰乱了我的页面标题部分。我想将按钮文本改为“返回”,而不是页面标题。知道怎么做吗? 最佳答案 如果您使用Storyboard,那么您可以在那里设置后退按钮标题,单击ViewController->

swift - 使 Button 跨越 VStack

我目前有以下SwiftUIView:HStack{...VStack{TextField{...}SecureField{...}Button{...}}...}我添加了一个.background(Color.green)到Button,如您所见,View与文本非常贴合。我想知道是否有办法调整按钮的宽度,使其填满VStack-类似于.fillUIStackView的模式. 最佳答案 最好的方法是通过.frame(maxWidth:.infinity)https://developer.apple.com/documentation/

swift - Text ("") 和 Text(verbatim : "") initializers in SwiftUI 之间的区别

我一直在关注Apple的SwiftUItutorials.在此过程中,我经常将Text对象与以下初始化程序一起使用:///Createsaninstancethatdisplays`content`verbatim.publicinit(_content:S)whereS:StringProtocol现在,在fifthtutorial在本系列中,我遇到了Text的以下用法:Text(verbatim:"")接口(interface)中的描述与其他初始化器相同:///Createsaninstancethatdisplays`content`verbatim.publicinit(ver

ios - Swift xcode 6 label.text 在 NSURLSession 中没有改变

这是一个简单的测试应用程序,用于演示如何从网络中提取数据。其中有一个由按钮操作触发的NSURLSession。importUIKitclassViewController:UIViewController{@IBOutletweakvarcity:UITextField!@IBOutletweakvarmessage:UILabel!@IBActionfuncbuttonPressed(sender:AnyObject){varurlString="http://www.weather-forecast.com/locations/"+city.text.stringByReplaci

swift : How to center cell text

我的swiftAPP有问题。在我写的TableViewCell函数中letcell=tableView.dequeueReusableCellWithIdentifier("Cell",forIndexPath:indexPath)asMyCellcell.setMyCell(self.data[0]["content"]!)如果我写cell.textAlignmentredlineappearandsay"textAlignmentinunavailable:APIdeprecated" 最佳答案 使用Swift4的人的正确答案是

javascript - 苹果 TVML : Send APP to background when Menu button pressed on Siri remote

在TVML应用程序中从SiriRemote按下“菜单”按钮时,我不知道如何将应用程序发送到后台。我是TVML开发的新手。我正在尝试TVML开发,并创建了一个小型演示应用程序,我会在应用程序启动后立即播放视频。现在问题是按照苹果的指导方针,如果我在我的根页面上,我按下siriRemote上的菜单按钮,那么我的应用程序应该进入后台。现在我的应用程序没有相应的行为。我尝试了很多解决方案,例如:如下所示注册我的appDelegate()成为FirstResponder-UIApplication.sharedApplication().beginReceivingRemoteControlEv