如何在向右滑动时设置底部图标的标题?

时间:2018-02-12 18:48:01

标签: ios swift

我想在tableViewCell右侧的图标底部显示标题。我正在编写像这样的单元格的代码

let moreBtnRight : MGSwipeButton = 
    MGSwipeButton(title: "More",icon:UIImage(named: "New menu_icon"),
    backgroundColor:UIColor(red: 235/255.0,green: 94/255.0, blue: 26/255.0, alpha: 0.9));
let emailBtnRight : MGSwipeButton = 
    MGSwipeButton(title: "EMail", icon:UIImage(named:"Swipe_Right_Email"),
    backgroundColor:UIColor(red: 235/255.0,green: 94/255.0, blue: 26/255.0, alpha: 0.9));
let messageBtnRight : MGSwipeButton = 
     MGSwipeButton(title: "SMS", icon:UIImage(named: "Swipe_Text_Right"),
     backgroundColor:UIColor(red: 235/255.0,green: 94/255.0, blue: 26/255.0, alpha: 0.9));

但是,此代码会在图标旁边显示标题 这是我得到的输出:

enter image description here

如何在图标底部设置标题。,请帮帮我吗? 提前谢谢

1 个答案:

答案 0 :(得分:0)

只是一个例子。您可以替换您的图标和标题。但这就是你应该怎么做的。使用库中的centerIconOverText函数:

let mail = MGSwipeButton(title: "Mail", icon: UIImage(named: "mail.png"), backgroundColor: UIColor.blue)
mail.centerIconOverText()  

以下是输出:

enter image description here