カスタムUIViewを幅と高さのスタイルに対応させようとしています。リアクション高さ/幅スタイルに対応するネイティブカスタムiOSビュー
#import "MyCustomView.h"
#import "RCTViewManager.h"
@implementation MyCustomView
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Create the component view
}
return self;
}
@end
とViewManager:
<MyCustomView style={{width: 200, height: 300}}/>
私はhttps://github.com/brentvatne/react-native-dashed-border-example
で簡単な例を密接に続いてきた現在、私の見るとViewManagerは次のようになりしかし
@implementation MyCustomViewManager
RCT_EXPORT_MODULE();
- (UIView *)view
{
return [[MyCustomView alloc] initWithFrame: [[UIScreen mainScreen] bounds]];
}
@end
これをコースは常に画面を満たします。私はこのコンポーネントの高さを設定することができ、理想的にはstyle
経由で渡すRNメソッドを使用することができます。私はシンプルなボーダー例に従った場合
、私は
@implementation MyCustomView
- (instancetype)init
{
self = [super init];
if (self) {
// Create the component view
}
return self;
}
@end
と
@implementation MyCustomViewManager
RCT_EXPORT_MODULE();
- (UIView *)view
{
return [[MyCustomView alloc] init];
}
@end
で終わるしかし、ビューが表示され、0.00であることをself.bounds.size.height
を報告していません。
これは私が逃したことがありますか?私はRCTBridgeを採用する必要がありますか?私は、以前のラインにhttps://github.com/brentvatne/react-native-dashed-border-example/blob/master/BVDashedBorderViewManager.m#L9のように
@synthesize bridge = _bridge;
を持っていなかったが、私はあなたのビューでreactSetFrameを上書きすることができます
私も '#import" UIView + React.h " – Adamski
ありがとう!私はそれを –