iOS implementation corner and shadow,border and so on

This commit is contained in:
pengfei.zhou 2019-08-02 17:45:47 +08:00
parent 9a94ed5dda
commit e5648242f7
2 changed files with 28 additions and 2 deletions

View File

@ -69,6 +69,32 @@ - (void)blendView:(UIView *)view forPropName:(NSString *)name propValue:(id)prop
view.userInteractionEnabled = YES; view.userInteractionEnabled = YES;
UITapGestureRecognizer *tapGesturRecognizer=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(onClick:)]; UITapGestureRecognizer *tapGesturRecognizer=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(onClick:)];
[view addGestureRecognizer:tapGesturRecognizer]; [view addGestureRecognizer:tapGesturRecognizer];
} else if([name isEqualToString:@"border"]) {
NSDictionary *dic = prop;
CGFloat width = [(NSNumber *)[dic objectForKey:@"width"] floatValue];
UIColor *color = DoricColor((NSNumber *)[dic objectForKey:@"color"]);
view.layer.borderWidth = width;
view.layer.borderColor = color.CGColor;
} else if([name isEqualToString:@"corners"]) {
if([prop isKindOfClass:NSNumber.class]) {
view.layer.cornerRadius = [(NSNumber *)prop floatValue];
} else if([prop isKindOfClass:NSDictionary.class]) {
}
} else if([name isEqualToString:@"shadow"]) {
NSDictionary *dic = prop;
CGFloat opacity = [(NSNumber *)[dic objectForKey:@"opacity"] floatValue];
if (opacity > CGFLOAT_MIN) {
view.clipsToBounds = NO;
UIColor *color = DoricColor((NSNumber *)[dic objectForKey:@"color"]);
view.layer.shadowColor = color.CGColor;
view.layer.shadowRadius = [(NSNumber *)[dic objectForKey:@"radius"] floatValue];
view.layer.shadowOffset = CGSizeMake([(NSNumber *)[dic objectForKey:@"offsetX"] floatValue],[(NSNumber *)[dic objectForKey:@"offsetY"] floatValue]);
view.layer.shadowOpacity = opacity;
} else {
view.clipsToBounds = YES;
}
} else { } else {
DoricLog(@"Blend View error for View Type :%@, prop is %@", self.class, name); DoricLog(@"Blend View error for View Type :%@, prop is %@", self.class, name);
} }

View File

@ -25,7 +25,7 @@ class CounterView extends ViewHolder {
color: Color.parse('#000000'), color: Color.parse('#000000'),
} }
this.counter.textSize = 20 this.counter.textSize = 20
//this.counter.corners = 5 this.counter.corners = 5
vlayout.space = 20 vlayout.space = 20
vlayout.layoutConfig = { vlayout.layoutConfig = {
alignment: new Gravity().center() alignment: new Gravity().center()