I can easily use TTTAttributedlabel
to have tappable url, name, etc.
1) How can I create something similar to that in CKLabelComponent
?
2) Do I need to use CKTextComponent
?
[CKLabelComponent newWithLabelAttributes:{
.string = @"This shall be context This shall be context This shall be context This shall be context",
.font = [UIFont fontWithName:@"Baskerville" size:14]
}
viewAttributes:{
{@selector(setBackgroundColor:), [UIColor clearColor]},
{@selector(setUserInteractionEnabled:), @NO},
}
size:{ }]
You could make you component easily. Provide the view, implement the
computeLayoutThatFits:
. CKImageComponent is an example.But at the situation of text. It may be hard, because of the layout size. Once you use
TTTAttributedLabel
as the render of text, you have to provide the text size manually. This is definitely not the thing you want.As you could see, CKTextComponent, the parent of CKLabelComponent, is implemented as a subproject of ComponentKit. It handle the layout size, text rendering, text layout cache. (It's implemented with TextKit.) If you want to use
TTTAttributedLabel
, you have to handle all things yourself with TTTAttributedLabel. It may slow down your scroll, because CKTextComponent implement async render but TTTAttributedLabel don't.CKTextKitEntityAttributeName
may achieve your goal