#import "XGHorizontalScrollComponent.h"#import <ComponentKit/CKComponentSubclass.h>@interfaceXGHorizontalScrollComponent()@property(nonatomic,strong)CKComponent*scrollComponent;@end@implementationXGHorizontalScrollComponent+(instancetype)newWithChildren:(std::vector<CKStackLayoutComponentChild>)children{CKComponentScopescope(self);CKComponent*content=[CKStackLayoutComponentnewWithView:{[UIScrollViewclass]}size:{}style:{.direction=CKStackLayoutDirectionHorizontal,.alignItems=CKStackLayoutAlignItemsStretch}children:{children}];XGHorizontalScrollComponent*component=[supernewWithComponent:content];if(component){component->_scrollComponent=content;}returncomponent;}@end@implementationXGHorizontalScrollComponentController-(void)didMount{[superdidMount];// Get scroll componentXGHorizontalScrollComponent*component=(XGHorizontalScrollComponent*)self.component;CKComponent*scrollComponent=component.scrollComponent;// Get component sizeCKSizeRangerange=CKSizeRange();CKComponentLayoutlayout=[scrollComponentcomputeLayoutThatFits:range];// Get scroll viewUIScrollView*scrollView=(UIScrollView*)scrollComponent.viewContext.view;// Set scroll view properties, you can custom scrollView herescrollView.showsHorizontalScrollIndicator=NO;scrollView.showsVerticalScrollIndicator=NO;// Set contentSize[scrollViewsetContentSize:layout.size];}// Invoked when the component is updated-(void)didUpdateComponent{[superdidUpdateComponent];// Update contentSizeXGHorizontalScrollComponent*component=(XGHorizontalScrollComponent*)self.component;CKComponent*scrollComponent=component.scrollComponent;CKSizeRangerange=CKSizeRange();CKComponentLayoutlayout=[scrollComponentcomputeLayoutThatFits:range];UIScrollView*scrollView=(UIScrollView*)scrollComponent.viewContext.view;[scrollViewsetContentSize:layout.size];}@end