-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Icon insets support for buttons (#4699)
* Add button.iconInsets * Define iconInsets in Options.ts * Apply color on button iconImage
- Loading branch information
Showing
10 changed files
with
137 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#import "RNNOptions.h" | ||
|
||
@interface RNNInsetsOptions : RNNOptions | ||
|
||
@property (nonatomic, strong) Double* top; | ||
@property (nonatomic, strong) Double* left; | ||
@property (nonatomic, strong) Double* right; | ||
@property (nonatomic, strong) Double* bottom; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#import "RNNInsetsOptions.h" | ||
|
||
@implementation RNNInsetsOptions | ||
|
||
- (instancetype)initWithDict:(NSDictionary *)dict { | ||
self = [super init]; | ||
|
||
self.top = [DoubleParser parse:dict key:@"top"]; | ||
self.left = [DoubleParser parse:dict key:@"left"]; | ||
self.bottom = [DoubleParser parse:dict key:@"bottom"]; | ||
self.right = [DoubleParser parse:dict key:@"right"]; | ||
|
||
return self; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#import <UIKit/UIKit.h> | ||
|
||
@interface UIImage (insets) | ||
|
||
- (UIImage *)imageWithInsets:(UIEdgeInsets)insets; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#import "UIImage+insets.h" | ||
|
||
@implementation UIImage (insets) | ||
|
||
- (UIImage *)imageWithInsets:(UIEdgeInsets)insets { | ||
UIGraphicsBeginImageContextWithOptions(CGSizeMake(self.size.width + insets.left + insets.right, | ||
self.size.height + insets.top + insets.bottom), false, self.scale); | ||
CGContextRef context = UIGraphicsGetCurrentContext(); | ||
UIGraphicsPushContext(context); | ||
|
||
CGPoint origin = CGPointMake(insets.left, insets.top); | ||
[self drawAtPoint:origin]; | ||
|
||
UIGraphicsPopContext(); | ||
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext(); | ||
UIGraphicsEndImageContext(); | ||
return newImage; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters