我想使用componentKit
in创建自定义视图objective-c
。该视图看起来像facebook
app 中的新闻提要视图,我编写了以下代码来制作该视图,
+ (instancetype)newWithText:(NSString *)text
context:(QuoteContext *)context
{
return [super newWithComponent:
[QuoteWithBackgroundComponent
newWithBackgroundImage:[context imageNamed:@""]
quoteComponent:
[CKInsetComponent
newWithInsets:{.top = 10, .bottom = 10, .left = 10, .right = 10}
component:
[CKFlexboxComponent
newWithView:{}
size:{}
style:{
.direction = CKFlexboxDirectionVertical,
// .spacing = 10,
}
children:{
{
// Profile Picture
[CKImageComponent
newWithImage: nil
attributes:{
{@selector(setBackgroundColor:), [UIColor darkGrayColor]},
{CKComponentViewAttribute::LayerAttribute(@selector(setCornerRadius:)), 17.5}
}
size:CKComponentSize::fromCGSize(CGSizeMake(35, 35))],
},
{
// Name
[CKInsetComponent
newWithInsets:{ .right= 140, .top= -35}
component:
[CKLabelComponent
newWithLabelAttributes:{
.string = @"Asim Iftikhar Abbasi",
.font = [UIFont fontWithName:@"Baskerville" size:20],
}
viewAttributes:{
{@selector(setBackgroundColor:), [UIColor whiteColor]},
{@selector(setUserInteractionEnabled:), @NO},
}
size:{ }]],
.alignSelf = CKFlexboxAlignSelfEnd, // Right aligned
},
{
// Location
[CKInsetComponent
newWithInsets:{.right= 185, .top= -10}
component:
[CKLabelComponent
newWithLabelAttributes:{
.string = @"2 hrs Islamabad, Pakistan",
.font = [UIFont fontWithName:@"Baskerville" size:12]
}
viewAttributes:{
{@selector(setBackgroundColor:), [UIColor whiteColor]},
{@selector(setUserInteractionEnabled:), @NO},
}
size:{ }
]],
.alignSelf = CKFlexboxAlignSelfEnd, // Right aligned
},
{
// Post
[CKInsetComponent
newWithInsets:{.right= 0, .top= 0}
component:
[CKImageComponent
newWithImage: nil
attributes:{{@selector(setBackgroundColor:), [UIColor blackColor]},
}
size:CKComponentSize::fromCGSize(CGSizeMake(400, 200))]],
.spacingBefore = 10
},
{
// Buttons
[CKInsetComponent
newWithInsets:{.right= 0, .top= 15}
component:
[CKButtonComponent
newWithAction:{}
options:{
.titles = @"Hello",
.attributes = {{@selector(setHighlighted:), @YES}},
.titleColors = titleColors,
.selected = YES,
}]],
.spacingBefore = 10
},
}]]]];
}
@end
我无法访问选项的属性
options:{
.titles = @"Hello",
.attributes = {{@selector(setHighlighted:), @YES}},
.titleColors = titleColors,
.selected = YES,
}
当我访问编译器的titles
属性时会button
产生以下错误:
use of undeclared identifier titles
任何人都请帮助我...在此先感谢