我一直在寻找谷歌对此的回答,但没有快乐。我想做的是将茶杯和ProMotion混合搭配用于桌子。整体表非常简单。只需将其添加到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中添加内容的子视图非常相似的内容。这些如何(好)共存?
有关如何将该tableview标签设为绿色的任何提示?甚至可能使用TeaCup添加一些自定义UILabels?
注意:我知道绿色很糟糕,但我只是为了证明我有正确的元素风格。一旦我的造型正确,我会选择更有品味的东西。
谢谢!
答案 0 :(得分:2)
我建议继承PM :: TableViewCell(它是UITableViewCell的子类)并在那里应用你的Teacup样式。
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