次のレイアウトを実装しようとしています。
Name: James
Gender: Male
Followers: Brian, Jason and Mike.
トップレベルでは CKStackLayout を使用することになると想像できますが、「名前: James」などの各エントリについて、ボックス内で名前を右揃えにするにはどうすればよいですか?
私は次のようなものを使用していました.テキストを固定幅コンポーネント内にラップし、ラベルコンポーネントをNSTextAlignmentRight
配置を使用するように設定しましたが、機能せず、左と右の両方が「左揃え」です:
static CKComponent *singleLine(NSString *left, NSString *right)
{
CKStackLayoutComponent *stackComponent =
[CKStackLayoutComponent
newWithView:{}
size:{}
style:{
.direction = CKStackLayoutDirectionHorizontal,
.alignItems = CKStackLayoutAlignItemsStretch,}
children:{
{.component = [CKStaticLayoutComponent
newWithView:{}
size:{.width = CKRelativeDimension(10)}]},
{.component =
[CKStaticLayoutComponent
newWithView:{}
size:{.width = CKRelativeDimension(88)}
children:{
{
.component =
[CKLabelComponent
newWithLabelAttributes:{
.string = left,
.alignment = NSTextAlignmentRight,
.font = [UIFont boldSystemFontOfSize:14.0],
.maximumNumberOfLines = 1
}
viewAttributes:{}],
}
}],
},
{
.component =
[CKLabelComponent
newWithLabelAttributes:{
.string = right,
.alignment = NSTextAlignmentLeft,
.font = [UIFont systemFontOfSize:14.0],
.maximumNumberOfLines = 1
}
viewAttributes:{}],
.spacingBefore = 10.0
}
}];
return stackComponent;
}
ありがとう!