我已经到处寻找 Google 对此问题的答案,但没有找到满意的答案。我想做的是将 Teacup 和 ProMotion 混合搭配用于 table 。整个表格非常简单。只需将其添加到 table_data
方法中数据元素的哈希值即可。
stylename: :leg_cell
-和-
Teacup::Stylesheet.new :main_screen do
style :leg_cell,
backgroundColor: UIColor.colorWithRed(238, green:238, blue:238, alpha: 1),
textColor: UIColor.greenColor
style UITableViewLabel,
textColor: UIColor.greenColor
end
用于样式表。但是... UITableViewLabel
被忽略,结果如下:
Symbiote 告诉我这是一个 UITableViewLabel,但我没有找到设置其样式的方法。此外,茶杯还提供了这些巧妙的功能:
layout do
# things here to add styled subviews
与在 ProMotion 中添加事物的 subview 非常相似的事物。这些如何共存?
关于如何使表格 View 标签样式为绿色的任何提示?甚至可能使用 TeaCup 添加一些自定义 UILabels?
注意:我知道绿色很糟糕,但我使用它只是为了证明我已经设置了正确的元素样式。一旦我得到正确的样式,我会选择更有品味的东西。
谢谢!
最佳答案
我建议子类化 PM::TableViewCell (它是 UITableViewCell 的子类)并在其中应用茶杯样式。
class MyTableViewCell < PM::TableViewCell
attr_accessor :mileage_label
stylesheet :main_screen
def layoutSubviews
layout do
# Subviews
# Apply `self.mileage_label` to your UILabel here.
end
restyle! # May be necessary?
end
end
class MyScreen < PM::TableScreen
def table_data
[{
cells: [{
cell_class: MyTableViewCell,
title: "whatever",
properties: {
mileage_label: "My mileage label",
}
}]
}]
end
end
关于uitableview - ProMotion 造型表格单元(带茶杯),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20055842/