diff --git a/.gitignore b/.gitignore index 52a4a912d..e7a954f8d 100644 --- a/.gitignore +++ b/.gitignore @@ -43,4 +43,6 @@ gradle/ # OS-specific files .DS_Store -.DS_Store? \ No newline at end of file +.DS_Store? +ios/TNSWidgets/TNSWidgets.xcodeproj/project.xcworkspace/xcuserdata/ +ios/TNSWidgets/TNSWidgets.xcodeproj/xcuserdata/ diff --git a/ios/TNSWidgets/TNSWidgets.xcodeproj/project.pbxproj b/ios/TNSWidgets/TNSWidgets.xcodeproj/project.pbxproj index d2043b482..964ae339b 100644 --- a/ios/TNSWidgets/TNSWidgets.xcodeproj/project.pbxproj +++ b/ios/TNSWidgets/TNSWidgets.xcodeproj/project.pbxproj @@ -7,6 +7,8 @@ objects = { /* Begin PBXBuildFile section */ + 8B7321CF1D097ECD00884AC6 /* TNSLabel.h in Headers */ = {isa = PBXBuildFile; fileRef = 8B7321CD1D097ECD00884AC6 /* TNSLabel.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 8B7321D01D097ECD00884AC6 /* TNSLabel.m in Sources */ = {isa = PBXBuildFile; fileRef = 8B7321CE1D097ECD00884AC6 /* TNSLabel.m */; }; F98F5CB31CD0EFEA00978308 /* TNSWidgets.h in Headers */ = {isa = PBXBuildFile; fileRef = F98F5CB21CD0EFEA00978308 /* TNSWidgets.h */; settings = {ATTRIBUTES = (Public, ); }; }; F98F5CBA1CD0EFEA00978308 /* TNSWidgets.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F98F5CAF1CD0EFEA00978308 /* TNSWidgets.framework */; }; F98F5CBF1CD0EFEA00978308 /* TNSWidgetsTests.m in Sources */ = {isa = PBXBuildFile; fileRef = F98F5CBE1CD0EFEA00978308 /* TNSWidgetsTests.m */; }; @@ -25,6 +27,8 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + 8B7321CD1D097ECD00884AC6 /* TNSLabel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TNSLabel.h; sourceTree = ""; }; + 8B7321CE1D097ECD00884AC6 /* TNSLabel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TNSLabel.m; sourceTree = ""; }; F98F5CAF1CD0EFEA00978308 /* TNSWidgets.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = TNSWidgets.framework; sourceTree = BUILT_PRODUCTS_DIR; }; F98F5CB21CD0EFEA00978308 /* TNSWidgets.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TNSWidgets.h; sourceTree = ""; }; F98F5CB41CD0EFEA00978308 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; @@ -76,6 +80,8 @@ isa = PBXGroup; children = ( F98F5CB21CD0EFEA00978308 /* TNSWidgets.h */, + 8B7321CD1D097ECD00884AC6 /* TNSLabel.h */, + 8B7321CE1D097ECD00884AC6 /* TNSLabel.m */, F98F5CC91CD0F09E00978308 /* UIImage+TNSBlocks.h */, F98F5CCA1CD0F09E00978308 /* UIImage+TNSBlocks.m */, F98F5CB41CD0EFEA00978308 /* Info.plist */, @@ -101,6 +107,7 @@ files = ( F98F5CB31CD0EFEA00978308 /* TNSWidgets.h in Headers */, F98F5CCB1CD0F09E00978308 /* UIImage+TNSBlocks.h in Headers */, + 8B7321CF1D097ECD00884AC6 /* TNSLabel.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -200,6 +207,7 @@ isa = PBXSourcesBuildPhase; buildActionMask = 2147483647; files = ( + 8B7321D01D097ECD00884AC6 /* TNSLabel.m in Sources */, F98F5CCC1CD0F09E00978308 /* UIImage+TNSBlocks.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; diff --git a/ios/TNSWidgets/TNSWidgets/TNSLabel.h b/ios/TNSWidgets/TNSWidgets/TNSLabel.h new file mode 100644 index 000000000..1c170b9c9 --- /dev/null +++ b/ios/TNSWidgets/TNSWidgets/TNSLabel.h @@ -0,0 +1,16 @@ +// +// TNSLabel.h +// TNSWidgets +// +// Created by Hristo Hristov on 6/9/16. +// Copyright © 2016 Telerik A D. All rights reserved. +// + +#import + +@interface TNSLabel : UILabel + +@property(nonatomic) UIEdgeInsets padding; +@property(nonatomic) UIEdgeInsets borderThickness; + +@end diff --git a/ios/TNSWidgets/TNSWidgets/TNSLabel.m b/ios/TNSWidgets/TNSWidgets/TNSLabel.m new file mode 100644 index 000000000..1f83846b4 --- /dev/null +++ b/ios/TNSWidgets/TNSWidgets/TNSLabel.m @@ -0,0 +1,28 @@ +// +// TNSLabel.m +// TNSWidgets +// +// Created by Hristo Hristov on 6/9/16. +// Copyright © 2016 Telerik A D. All rights reserved. +// + +#import "TNSLabel.h" + +@implementation TNSLabel + + +- (CGRect)textRectForBounds:(CGRect)bounds limitedToNumberOfLines:(NSInteger)numberOfLines { + CGSize size = [super textRectForBounds:bounds limitedToNumberOfLines:numberOfLines].size; + return CGRectMake( + - (self.borderThickness.left + self.padding.left), + - (self.borderThickness.right + self.padding.right), + size.width + self.borderThickness.left + self.padding.left + self.padding.right + self.borderThickness.right, + size.height + self.borderThickness.top + self.padding.top + self.padding.bottom + self.borderThickness.bottom + ); +} + +-(void)drawTextInRect:(CGRect)rect { + [super drawTextInRect:UIEdgeInsetsInsetRect(UIEdgeInsetsInsetRect(rect, self.borderThickness), self.padding)]; +} + +@end diff --git a/ios/TNSWidgets/TNSWidgets/TNSWidgets.h b/ios/TNSWidgets/TNSWidgets/TNSWidgets.h index 29b88ffb7..4ae01b174 100644 --- a/ios/TNSWidgets/TNSWidgets/TNSWidgets.h +++ b/ios/TNSWidgets/TNSWidgets/TNSWidgets.h @@ -17,4 +17,4 @@ FOUNDATION_EXPORT const unsigned char TNSWidgetsVersionString[]; // In this header, you should import all the public headers of your framework using statements like #import #import "UIImage+TNSBlocks.h" - +#import "TNSLabel.h"