gpt4 book ai didi

ios - 更改 UITableViewRowAction 标题文本的颜色

转载 作者:行者123 更新时间:2023-11-30 13:23:15 25 4
gpt4 key购买 nike

我想更改 UITableViewRowAction 标题的颜色。我希望“下载”用红色书写。

enter image description here

这是按钮的代码 -

func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [UITableViewRowAction]? {


let downloadButton = UITableViewRowAction(style: .Normal, title: "Download") { action, index in

var url: String

if self.searchController.active {
url = String(self.filteredPapers[indexPath.row].url)
} else {
url = String(self.papers[indexPath.row].url)
}

url = url.stringByReplacingOccurrencesOfString(" ", withString: "%20")
print(url)
let destination = Alamofire.Request.suggestedDownloadDestination(directory: .DocumentDirectory, domain: .UserDomainMask)

self.table.editing = false

Alamofire.download(.GET, url, destination: destination).response { _, _, _, error in
if let error = error {
print("Failed with error: \(error)")
} else {
print("Downloaded file successfully")
}
}

}

downloadButton.backgroundColor = UIColor(red:0.79, green:0.79, blue:0.81, alpha:1.0)


return [downloadButton]

}

最佳答案

由于 UITableViewRowActionUIButton 的一种类型,我们可以通过更改 UIButton 类的外观来更改文本颜色。在您的代码中添加以下代码editActionsForRowAtIndexPath

UIButton.appearance().setTitleColor(UIColor.redColor(), forState: UIControlState.Normal)

输出:

enter image description here

关于ios - 更改 UITableViewRowAction 标题文本的颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37531444/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com