Skip to content

Commit

Permalink
Padding for textfield and textarea
Browse files Browse the repository at this point in the history
  • Loading branch information
gliechtenstein committed Jan 4, 2017
1 parent 8468389 commit 20260d6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
10 changes: 8 additions & 2 deletions app/Jasonette/JasonTextareaComponent.m
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ + (UIView *)build: (SZTextView *)component withJSON: (NSDictionary *)json withOp
[self stylize:mutated_json component:component];

// 2. Custom Style

if(style[@"padding"]){
int padding = [style[@"padding"] intValue];
int lineFragmentPadding = component.textContainer.lineFragmentPadding;

component.textContainerInset = UIEdgeInsetsMake(padding, padding-lineFragmentPadding, padding, padding-lineFragmentPadding);
}

if(mutated_json[@"placeholder"]){
UIColor *placeholder_color;
NSString *placeholder_raw_str = mutated_json[@"placeholder"];
Expand Down Expand Up @@ -90,8 +98,6 @@ + (UIView *)build: (SZTextView *)component withJSON: (NSDictionary *)json withOp
}
UIFont *f = [UIFont fontWithName:font size:size];
[placeholderStr addAttribute:NSFontAttributeName value:f range:NSMakeRange(0, placeholderStr.length)];


component.attributedPlaceholder = placeholderStr;
}

Expand Down
8 changes: 8 additions & 0 deletions app/Jasonette/JasonTextfieldComponent.m
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ + (UIView *)build: (UITextField *)component withJSON: (NSDictionary *)json withO

// 2. Custom Style
NSDictionary *style = json[@"style"];

if(style[@"padding"]){
int padding = [style[@"padding"] intValue];
component.layer.sublayerTransform = CATransform3DMakeTranslation(padding, 0, 0);
}



if(style){
if(style[@"secure"] && [style[@"secure"] boolValue]){
((UITextField *)component).secureTextEntry = YES;
Expand Down

0 comments on commit 20260d6

Please sign in to comment.