草庐IT

悬浮按钮

全部标签

ios - 如何为 AppDelegate 中的所有 View Controller 独立更改左右栏按钮项文本属性?

在我的应用程序中,我在UINavigationController中嵌入了许多UIViewControllers,其中包含一个cancelrightBarButtonItem和保存leftBarButtonItem。在每个类中,我都有重复的代码来自定义栏按钮项的属性:navigationItem.leftBarButtonItem?.setTitleTextAttributes([NSAttributedStringKey.font:UIFont(name:fontFuturaMedium,size:fontSize17)!],for:.normal)navigationItem.le

ios - Swift Tableview 单元格按钮图像根据 tableview 数据更改

我正在尝试解析JSON并在tableview数组中附加JSON响应值。在下面的响应subcategory中,我正在获取一些对象的值,但其中一些对象为null。{"category":[{"id":0,"subcategory":[//Tablecellbuttonneedtoshowgreencolor{"subcategory_id":10}]},{"id":0,"subcategory":null//Tablecellbuttonneedtoshowredcolor}]}我需要将值附加到数组中,例如:[10,null,....]。如果子类别null意味着我需要存储null,否则它的

ios - 通过按钮替换 ViewController,线程 1 : EXC_BAD_INSTRUCTION

我想用一个ViewController替换我的UITableViewController,里面有一个UITableView。为此,我使用以下代码:@objcfuncbuttonAction(sender:UIButton!){letnewController=storyboard?.instantiateViewController(withIdentifier:"VcId")as!JobTableViewControllerself.navigationController?.present(newController,animated:true,completion:nil)}但是

ios - 在点击 View 的一部分时,如何真正隐藏和显示标签栏? (没有按钮,但屏幕的任何位置)

overridefuncviewDidLoad(){lettap=UITapGestureRecognizer(target:self,action:#selector(touchHandled))view.addGestureRecognizer(tap)}@objcfunctouchHandled(){tabBarController?.hideTabBarAnimated(hide:true)}extensionUITabBarController{funchideTabBarAnimated(hide:Bool){UIView.animate(withDuration:2,an

ios - 单击按钮时 UITextField 为零,但适用于更改

单击按钮时出现以下错误Thread1:Fatalerror:UnexpectedlyfoundnilwhileunwrappinganOptionalvalue代码如下@IBOutletweakvarUserId:UITextField!{didSet{UserId.setBottomBorder()UserId.delegate=self}}@IBOutletweakvarPassword:UITextField!{didSet{Password.setBottomBorder()Password.delegate=self}}@IBActionfunclogincta(_sende

ios - 为什么单击按钮时安全文本输入无法正常工作

我将一个按钮设置为带有隐藏图标的密码文本字段。在密码中开始编辑时会显示该图标。它是这样给出的...functextFieldDidBeginEditing(_textField:UITextField){fortextfieldintextFields{iftextfield.tag==1{textfield.isValid=true}else{textfield.isActive=false}}}当textfield.isValid=true时,一个didSet在另一个类中被调用,就像这样......varisValid:Bool=false{didSet{setCorrectSta

ios - 如何将动画添加到自定义按钮并在点击按钮时调用?

这个问题在这里已经有了答案:CustomUIButtonclassforbuttontouchevent(2个答案)关闭3年前。我创建了一个自定义按钮类,它是UIButton的子类,并编写一个UIButton扩展。这是我的扩展:extensionUIButton{funcsetButtonCurvy(){self.layer.cornerRadius=self.frame.size.height/2}//ThisfunctionshouldberunwhenbuttontappedfuncbuttonTapped(_completion:@escaping()->Void){letan

ios - 按钮单击 TableView 以更改我的 TableView 单元格中的图像

我有一个带有一个按钮的表格View单元格。单击具有一种方法的单元格按钮来检查是否按钮标记等于indexPath.row。然后我试图改变形象。但它没有显示。-(UITableViewCell*)tableView:(UITableView*)tableViewcellForRowAtIndexPath:(NSIndexPath*)indexPath{staticNSString*CellIdentifier=@"FilterTableViewCell";FilterTableViewCell*cell=[tableViewdequeueReusableCellWithIdentifier

ios - 语音输入无法访问文本字段上的清除按钮- swift

我正在尝试通过语音来访问文本字段的清除按钮,但它似乎不起作用。有人以前有这个问题吗?这是黑屏上的简单文本字段。当我尝试添加号码时,它在我的联系人列表上可以正常工作。在这种情况下,如何访问按钮以将其accessibilityElement设置为true? 最佳答案 尝试使用以下代码片段来显示清除按钮:@IBOutletweakvarmyTextField:UITextField!overridefuncviewDidAppear(_animated:Bool){super.viewDidAppear(animated)ifletcle

ios - 根据按钮数量设置 CollectionView 单元格高度

我有一个CollectionView,它将有一个UILabel和2-5个UIButton。我希望根据每个单元格显示多少个按钮来调整单元格的大小。我知道每个按钮的高度大约为100。classmyViewController:UIViewController{varmyCollectionView:UICollectionView!overridefuncviewDidLoad(){super.viewDidLoad()letlayout=UICollectionViewFlowLayout()layout.sectionInset=UIEdgeInsets(top:0,left:0,bo