标签: componentkit

为什么Facebook使用UICollectionView而不是UITableView作为他们的新闻Feed

如果有人不知道,Facebook开源了一个名为componentkit的新库

文件说

当与UICollectionView一起使用时,ComponentKit确实很有用.

Facebook为他们的新闻提供了这个lib.这意味着他们正在使用UICollectionView而不是我认为的UITableView.

为什么Facebook使用UICollectionView而不是UITableView?

我的意思是新闻源实际上是一个表格视图?

你有什么主意吗?你怎么看待这件事?

facebook uitableview uicollectionview componentkit

3
推荐指数
1
解决办法
1411
查看次数

如何使用CKStackLayoutComponent水平对齐两个标签?

我刚刚开始玩ComponentKit,我在水平对齐2个标签时遇到了一些困难.我希望第一个靠近左边距,第二个靠近右边.

使用自动布局,我可以使用这组约束来完成:

H:|-0-[_label1]-[_label2]-0-|

我尝试过的所有东西似乎都不起作用,我总是得到相同的结果:两个标签左对齐.

这是超级简单的组件:

+ (instancetype)newWithText1:(NSString *)text1 text2:(NSString *)text2
{
  return [super
          newWithComponent:
          [CKStackLayoutComponent
           newWithView:{}
           size:{}
           style:{
             .direction = CKStackLayoutDirectionHorizontal,
             .alignItems = CKStackLayoutAlignItemsCenter
           }
           children:{
             {
               [CKLabelComponent
                newWithLabelAttributes:{
                  .string = text1,
                  .font = [UIFont systemFontOfSize:20],
                  .color = [UIColor blackColor]
                }
                viewAttributes:{
                  {@selector(setBackgroundColor:), [UIColor clearColor]}
                }],
               .alignSelf = CKStackLayoutAlignSelfStretch
             },
             {
               [CKLabelComponent
                newWithLabelAttributes:{
                  .string = text2,
                  .font = [UIFont systemFontOfSize:20],
                  .color = [UIColor redColor],
                  .alignment = NSTextAlignmentRight
                }
                viewAttributes:{
                  {@selector(setBackgroundColor:), [UIColor clearColor]}
                }],
               .alignSelf = CKStackLayoutAlignSelfStretch
             }
           }]];
}
Run Code Online (Sandbox Code Playgroud)

如果有人有任何建议,将不胜感激.

componentkit

2
推荐指数
1
解决办法
656
查看次数