我很难为Titanium/Appc创建IOS模块,我正在尝试集成https://github.com/antiguab/BAFluidView所以我可以在钛中使用它。
我遵循了模块教程,让它只适用于标准视图,但当我尝试添加BAFluidView时,它不起作用。
我已经在xcode中包含了这些类,并有下面的代码。
#import "ComExampleFluidView.h"
#import "TiUtils.h"
#import "BAFluidView.h"
#import "UIColor+ColorWithHex.h"
@implementation ComExampleFluidView
- (void)initializeState
{
// Creates and keeps a reference to the view upon initialization
square = [[UIView alloc] initWithFrame:[self frame]];
BAFluidView *view = [[BAFluidView alloc] initWithFrame:view.frame];
[view fillTo:@1.0];
view.fillColor = [UIColor colorWithHex:0x397ebe];
[view startAnimation];
[square addSubview:view];
[self addSubview:square];
[super initializeState];
}
-(void)dealloc
{
// Deallocates the view
RELEASE_TO_NIL(square);
[super dealloc];
}
-(void)frameSizeChanged:(CGRect)frame bounds:(CGRect)bounds
{
// Sets the size and position of the view
[TiUtils setView:square positionRect:bounds];
}
-(void)setColor_:(id)color
{
// Assigns the view's background color
square.backgroundColor = [[TiUtils colorValue:color] _color];
}
@end
头文件是
#import "TiUIView.h"
@interface ComExampleFluidView: TiUIView {
UIView *square;
}
@end
有人能对此提出一些建议吗?
由于您正在尝试桥接原生视图,因此需要一些布局助手来正确处理Titanium布局系统。请检查像ti.googlemaps这样的模块,尤其是视图的初始化。此外,像setColor
这样的自定义setter需要将颜色应用于BAFluidView
,而不是UIView
,因此您需要在页眉中保留该颜色的引用。我想ti.googlemaps的例子应该解释你正在寻找的所有概念。祝你好运