Skip to content

Commit

Permalink
Override UIFontTextStyles as macro
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowone committed Sep 23, 2013
1 parent 701c44a commit 22c7c02
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 18 deletions.
2 changes: 0 additions & 2 deletions UI7Kit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@
38AF0E8217EDF3DE00CF0C30 /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 38AF0E7F17EDF3DE00CF0C30 /* [email protected] */; };
38AF0E8317EDF3DE00CF0C30 /* [email protected] in Resources */ = {isa = PBXBuildFile; fileRef = 38AF0E7F17EDF3DE00CF0C30 /* [email protected] */; };
38AF0E8617EDFF2D00CF0C30 /* UITIssue68ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 38AF0E8517EDFF2D00CF0C30 /* UITIssue68ViewController.m */; };
38AF0E8717EDFF2D00CF0C30 /* UITIssue68ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 38AF0E8517EDFF2D00CF0C30 /* UITIssue68ViewController.m */; };
38AF86CF1769BC8000BFBD29 /* libUI7Kit.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 38017423176989650049D26C /* libUI7Kit.a */; };
38B9678317AC2DE90061E1EC /* UICRoundedRectButtonViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 38B9678217AC2DE90061E1EC /* UICRoundedRectButtonViewController.m */; };
38BC0E5D173E821700F36497 /* UITSubviewTableViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 38BC0E5B173E821700F36497 /* UITSubviewTableViewController.m */; };
Expand Down Expand Up @@ -1041,7 +1040,6 @@
buildActionMask = 2147483647;
files = (
38DBEB79178C6A27000EFC5C /* UICUserDefaults.m in Sources */,
38AF0E8717EDFF2D00CF0C30 /* UITIssue68ViewController.m in Sources */,
3865159D17A89D2900E10B72 /* UI7Tool.m in Sources */,
38B9678317AC2DE90061E1EC /* UICRoundedRectButtonViewController.m in Sources */,
38FB2AA2178F06B1000491FE /* UICBareTableViewController.m in Sources */,
Expand Down
23 changes: 16 additions & 7 deletions UI7Kit/UI7Font.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,25 @@

#import <UI7Kit/UI7Utilities.h>

#if __IPHONE_OS_VERSION_MAX_ALLOWED < 70000
UIKIT_EXTERN NSString *const UIFontTextStyleHeadline;
UIKIT_EXTERN NSString *const UIFontTextStyleBody;
UIKIT_EXTERN NSString *const UIFontTextStyleSubheadline;
UIKIT_EXTERN NSString *const UIFontTextStyleFootnote;
UIKIT_EXTERN NSString *const UIFontTextStyleCaption1;
UIKIT_EXTERN NSString *const UIFontTextStyleCaption2;
UIKIT_EXTERN NSString *const UI7FontTextStyleHeadline;
UIKIT_EXTERN NSString *const UI7FontTextStyleSubheadline;
UIKIT_EXTERN NSString *const UI7FontTextStyleBody;
UIKIT_EXTERN NSString *const UI7FontTextStyleFootnote;
UIKIT_EXTERN NSString *const UI7FontTextStyleCaption1;
UIKIT_EXTERN NSString *const UI7FontTextStyleCaption2;


#define UIFontTextStyleHeadline UI7FontTextStyleHeadline
#define UIFontTextStyleSubheadline UI7FontTextStyleSubheadline
#define UIFontTextStyleBody UI7FontTextStyleBody
#define UIFontTextStyleFootnote UI7FontTextStyleFootnote
#define UIFontTextStyleCaption1 UI7FontTextStyleCaption1
#define UIFontTextStyleCaption2 UI7FontTextStyleCaption2

#if __IPHONE_OS_VERSION_MAX_ALLOWED < 70000
@interface UIFont (iOS7)

//*
+ (UIFont *)preferredFontForTextStyle:(NSString *)style;

@end
Expand Down
16 changes: 8 additions & 8 deletions UI7Kit/UI7Font.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@

#import "UI7Font.h"

#if __IPHONE_OS_VERSION_MAX_ALLOWED < 70000
NSString *const UIFontTextStyleHeadline = @"UICTFontTextStyleHeadline";
NSString *const UIFontTextStyleSubheadline = @"UICTFontTextStyleSubhead";
NSString *const UIFontTextStyleBody = @"UICTFontTextStyleBody";
NSString *const UIFontTextStyleFootnote = @"UICTFontTextStyleFootnote";
NSString *const UIFontTextStyleCaption1 = @"UICTFontTextStyleCaption1";
NSString *const UIFontTextStyleCaption2 = @"UICTFontTextStyleCaption2";
#endif

NSString *const UI7FontTextStyleHeadline = @"UICTFontTextStyleHeadline";
NSString *const UI7FontTextStyleSubheadline = @"UICTFontTextStyleSubhead";
NSString *const UI7FontTextStyleBody = @"UICTFontTextStyleBody";
NSString *const UI7FontTextStyleFootnote = @"UICTFontTextStyleFootnote";
NSString *const UI7FontTextStyleCaption1 = @"UICTFontTextStyleCaption1";
NSString *const UI7FontTextStyleCaption2 = @"UICTFontTextStyleCaption2";


NSString *const UI7FontAttributeNone = nil;
Expand All @@ -30,6 +29,7 @@
NSString *const UI7FontAttributeCondensedBold = @"CondensedBold";
NSString *const UI7FontAttributeCondensedBlack = @"CondensedBlack";


@implementation UIFont (Patch)

+ (UIFont *)__preferredFontForTextStyle:(NSString *)style {
Expand Down
4 changes: 3 additions & 1 deletion UI7KitTestApp/UITTextViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ - (void)viewDidLoad {
self.textView.placeholderString = @"This is long long place holder may work ";
// Do any additional setup after loading the view from its nib.
self.textView.placeholderTextView.textAlignment = NSTextAlignmentCenter;
self.textView.font = [UIFont preferredFontForTextStyle:UIFontTextStyleBody];

UIFont *newFont = [UIFont preferredFontForTextStyle:UIFontTextStyleBody];
self.textView.font = newFont;
}

- (void)switched:(UISwitch *)sender {
Expand Down

0 comments on commit 22c7c02

Please sign in to comment.