简体   繁体   English

Swift:设置UITableViewRowAction按钮大小

[英]Swift: Set UITableViewRowAction button size

I have a short question: how can I programmatically set the UITableViewRowAction button size? 我有一个简短的问题:如何以编程方式设置UITableViewRowAction按钮大小? Is there a specific native method or I have to make custom buttons for that? 是否有特定的本机方法或我必须为此制作自定义按钮? I have been struggling with this for many hours and search for an answer all over the internet. 我一直在努力解决这个问题很长时间,并在互联网上寻找答案。

Thanks! 谢谢!

Unfortunately, you can't. 不幸的是,你做不到。 The button is the height of the containing cell and the width of the string, plus 15 points of padding on the left and right. 按钮是包含单元格的高度和字符串的宽度,以及左侧和右侧的15个填充点。 The only customizable properties of UITableViewRowAction are UITableViewRowAction唯一可自定义的属性是

  1. backgroundColor 背景颜色
  2. style 样式
  3. title 标题

You can fake a wider button by adding whitespace characters to the title string. 您可以通过在标题字符串中添加空格字符来伪造更宽的按钮。

UITableViewRowAction

For Width: You can add an empty string to: 对于宽度:您可以将空字符串添加到:

UITableViewRowAction(style: .Destructive, title: "     ")

It can helps to setup width not exactly (non-pixels accuracy) 它可以帮助设置宽度不精确(非像素精度)

For Height: Set cell height in TableView. 对于高度:在TableView中设置单元格高度。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM