TestsTested | ✗ |
LangLanguage | Obj-CObjective C |
License | MIT |
ReleasedLast Release | Dec 2014 |
Maintained by Yichi Zhang.
A few classes and categories to help make working with Ion Icons easier (sweetmandm/ionicons-iOS, pod name: 'ionicons'). You don't have to configure size and color on an ad hoc basis anymore; just configure the colors and sizes for each UI element in the settings dictionary on the singleton object of YZIonIconsHelper, then create new UIElements with the additional factory methods.
This is how I used to use 'ionicons':
// View Controller 1
CGFloat size = 22.0;
CGColor color = [UIColor darkGrayColor];
self.navigationItem.leftBarButtonItem =
[[UIBarButtonItem alloc]
initWithImage:[IonIcons imageWithIcon:icon_navicon
size:size
color:color
]
style:UIBarButtonItemStylePlain
target:self
action:someSelector
];
// View Controller 2
CGFloat size = 22.0;
CGColor color = [UIColor darkGrayColor];
self.navigationItem.leftBarButtonItem =
[[UIBarButtonItem alloc]
initWithImage:[IonIcons imageWithIcon:icon_navicon
size:size
color:color
]
style:UIBarButtonItemStylePlain
target:self
action:someSelector
];
I don't want to repeat the configurations any more.
CGFloat size = 22.0;
CGColor color = [UIColor darkGrayColor];
With YZIonIconsHelper, configure once,
[YZIonIconsHelper changeSettingsForClass:[UIBarButtonItem class]
key:yz_icon_normal_color
value:[UIColor darkGrayColor]
];
[YZIonIconsHelper changeSettingsForClass:[UIBarButtonItem class]
key:yz_icon_size
value:@(22)
];
Then:
// View Controller 1
self.navigationItem.leftBarButtonItem =
[UIBarButtonItem yz_barButtonItemWithIonIcon:icon_navicon
target:nil
action:nil
];
// View Controller 2
self.navigationItem.leftBarButtonItem =
[UIBarButtonItem yz_barButtonItemWithIonIcon:icon_navicon
target:nil
action:nil
];
No more
CGFloat size = 22.0;
CGColor color = [UIColor darkGrayColor];
It is recommended that you use cocoapods to add YZIonIconsHelper. If you've never used CocoaPods, check out their page:
pod 'YZIonIconsHelper'
to you Podfile
pod install
command in the directory that contains your Podfilexcworkspace
fileInfo.plist
file, add ionicons.ttf
to Fonts provided by application
You can either follow Step 2 on sweetmandm/ionicons-iOS or continue on to follow my instructions (which is copied from sweetmandm/ionicons-iOS anyway)
Modify your project's Info.plist file:
#import "YZIonIconsHelperImportAll.h"
You are ready to go.
You have to use cocoapods
to prepare the Demo Project.
Since Pods
are ignored, you have to run pod install
in the demo project directory.
Then open the xcworkspace
file.