Commit 18566676 authored by mei's avatar mei

no message

parents
# Created by http://www.gitignore.io
### Xcode ###
build
*.xcodeproj/*
!*.xcodeproj/project.pbxproj
!*.xcworkspace/contents.xcworkspacedata
### Objective-C ###
# OS X
.DS_Store
# Xcode
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
profile
*.moved-aside
DerivedData
*.hmap
*.ipa
# CocoaPods
Pods
\ No newline at end of file
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "group:Cruiser.xcodeproj">
</FileRef>
<FileRef
location = "group:Pods/Pods.xcodeproj">
</FileRef>
</Workspace>
//
// ICRAppDelegate.h
// Cruiser
//
// Created by Xummer on 3/23/15.
// Copyright (c) 2015 Xummer. All rights reserved.
//
#import <UIKit/UIKit.h>
@class ICRAppViewControllerManager;
@interface ICRAppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (readonly, assign, nonatomic) ICRAppViewControllerManager *m_appViewControllerMgr;
@end
//
// ICRAppDelegate.m
// Cruiser
//
// Created by Xummer on 3/23/15.
// Copyright (c) 2015 Xummer. All rights reserved.
//
#import "ICRAppDelegate.h"
#import "ICRAppViewControllerManager.h"
@implementation ICRAppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyWindow];
_m_appViewControllerMgr = [ICRAppViewControllerManager getAppViewControllerManager];
[self.window makeKeyAndVisible];
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
- (void)applicationDidEnterBackground:(UIApplication *)application {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
- (void)applicationWillEnterForeground:(UIApplication *)application {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
- (void)applicationWillTerminate:(UIApplication *)application {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
@end
//
// ICRAppViewControllerManager.h
// Cruiser
//
// Created by Xummer on 3/23/15.
// Copyright (c) 2015 Xummer. All rights reserved.
//
#import "IBTObject.h"
#import "IBTTabBarController.h"
#define CR_NAME_HOME @"Home"
#define CR_NAME_STORE @"Store"
#define CR_NAME_SYNC @"Sync"
#define CR_NAME_SYSTEM @"System"
typedef NS_ENUM(NSUInteger, CRTapBarItemIndex) {
kCRHome = 0,
kCRStore,
kCRSync,
kCRSystem,
};
static NSString * const ACETapBarItemNames[] = {
[ kCRHome ] = CR_NAME_HOME,
[ kCRStore ] = CR_NAME_STORE,
[ kCRSync ] = CR_NAME_SYNC,
[ kCRSystem ] = CR_NAME_SYSTEM,
};
@interface ICRAppViewControllerManager : IBTObject
{
UIWindow *m_window;
NSMutableArray *m_arrViewController;
NSMutableArray *m_arrTabBarBaseViewController;
IBTTabBarController *m_tabbarController;
}
+ (UINavigationController *)getCurrentNavigationController;
+ (IBTTabBarController *)getTabBarController;
+ (ICRAppViewControllerManager *)getAppViewControllerManager;
- (id)initWithWindow:(UIWindow *)window;
- (CGSize)getRootViewSize;
- (UIViewController *)getTabBarBaseViewController:(CRTapBarItemIndex)index;
- (IBTTabBarController *)getTabBarController;
- (NSUInteger)getCurTabBarIndex;
- (void)openFirstView;
- (void)openMainFrame;
- (void)createHomeViewController;
- (void)createStoreViewController;
- (void)createSyncViewController;
- (void)createSystemViewController;
@end
//
// ICRAppViewControllerManager.m
// Cruiser
//
// Created by Xummer on 3/23/15.
// Copyright (c) 2015 Xummer. All rights reserved.
//
#import "ICRAppViewControllerManager.h"
#import "ICRUIAppearance.h"
#import "IBTUINavigationController.h"
#import "ICRLoginViewController.h"
#import "ICRHomeViewController.h"
#import "ICRStoreViewController.h"
#import "ICRSyncViewController.h"
#import "ICRSystemViewController.h"
@interface ICRAppViewControllerManager ()
<
UITabBarControllerDelegate
>
@end
@implementation ICRAppViewControllerManager
+ (UINavigationController *)getCurrentNavigationController {
return nil;
}
+ (IBTTabBarController *)getTabBarController {
return [[self getAppViewControllerManager] getTabBarController];
}
+ (ICRAppViewControllerManager *)getAppViewControllerManager {
static ICRAppViewControllerManager *_sharedMgr = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
UIWindow *keyWindow = [UIApplication sharedApplication].keyWindow;
_sharedMgr = [[ICRAppViewControllerManager alloc] initWithWindow:keyWindow];
});
return _sharedMgr;
}
- (id)initWithWindow:(UIWindow *)window {
self = [super init];
if (!self) {
return nil;
}
[ICRUIAppearance CustomAppearance];
m_window = window;
m_arrTabBarBaseViewController = [NSMutableArray array];
m_arrViewController = [NSMutableArray array];
// Automatic login
ICRUserUtil *userUtil = [ICRUserUtil sharedInstance];
if ([userUtil isLogin]) {
[self openMainFrame];
}
else {
[self openFirstView];
}
return self;
}
- (void)dealloc {
m_window = nil;
m_arrViewController = nil;
m_arrTabBarBaseViewController = nil;
m_tabbarController = nil;
}
#pragma mark - Public Method
- (CGSize)getRootViewSize {
return m_window.rootViewController.view.frame.size;
}
- (IBTTabBarController *)getTabBarController {
return m_tabbarController;
}
- (NSUInteger)getCurTabBarIndex {
return m_tabbarController.selectedIndex;
}
- (UIViewController *)getTabBarBaseViewController:(CRTapBarItemIndex)index {
if (index > kCRSystem || index > [m_arrTabBarBaseViewController count]) {
return nil;
}
return m_arrTabBarBaseViewController[ index ];
}
- (void)openFirstView {
if ([m_window.rootViewController isKindOfClass:[IBTUINavigationController class]]) {
IBTUINavigationController *navCtrl = (IBTUINavigationController *)m_window.rootViewController;
if ([[navCtrl.viewControllers lastObject] isKindOfClass:[ICRLoginViewController class]]) {
return;
}
else if ([[navCtrl.viewControllers firstObject] isKindOfClass:[ICRLoginViewController class]]) {
[navCtrl popToRootViewControllerAnimated:YES];
return;
}
}
ICRLoginViewController *loginCtrl = [[ICRLoginViewController alloc] init];
IBTUINavigationController *naviCtrl = [[IBTUINavigationController alloc] initWithRootViewController:loginCtrl];
naviCtrl.navigationBarHidden = YES;
m_window.rootViewController = naviCtrl;
}
- (void)openMainFrame {
if (m_window.rootViewController &&
m_window.rootViewController == m_tabbarController) {
return;
}
[m_arrTabBarBaseViewController removeAllObjects];
[m_arrViewController removeAllObjects];
[self createHomeViewController];
[self createStoreViewController];
[self createSyncViewController];
[self createSystemViewController];
if (!m_tabbarController) {
m_tabbarController = [[IBTTabBarController alloc] init];
m_tabbarController.delegate = self;
}
[m_tabbarController setViewControllers:m_arrViewController];
[m_tabbarController setSelectedIndex:kCRHome];
m_window.rootViewController = m_tabbarController;
}
#pragma mark - Creation
- (void)createHomeViewController {
NSString *nsTitle = ACETapBarItemNames[ kCRHome ];
ICRHomeViewController *homeVCtrl = [[ICRHomeViewController alloc] init];
[m_arrTabBarBaseViewController addObject:homeVCtrl];
homeVCtrl.title = [IBTCommon localizableString:nsTitle];
IBTUINavigationController *navCtrl = [[IBTUINavigationController alloc] initWithRootViewController:homeVCtrl];
[m_arrViewController addObject:navCtrl];
navCtrl.title = nsTitle;
}
- (void)createStoreViewController {
NSString *nsTitle = ACETapBarItemNames[ kCRStore ];
ICRStoreViewController *storeVCtrl = [[ICRStoreViewController alloc] init];
[m_arrTabBarBaseViewController addObject:storeVCtrl];
storeVCtrl.title = [IBTCommon localizableString:nsTitle];
IBTUINavigationController *navCtrl = [[IBTUINavigationController alloc] initWithRootViewController:storeVCtrl];
[m_arrViewController addObject:navCtrl];
navCtrl.title = nsTitle;
}
- (void)createSyncViewController {
NSString *nsTitle = ACETapBarItemNames[ kCRSync ];
ICRSyncViewController *syncVCtrl = [[ICRSyncViewController alloc] init];
[m_arrTabBarBaseViewController addObject:syncVCtrl];
syncVCtrl.title = [IBTCommon localizableString:nsTitle];
IBTUINavigationController *navCtrl = [[IBTUINavigationController alloc] initWithRootViewController:syncVCtrl];
[m_arrViewController addObject:navCtrl];
navCtrl.title = nsTitle;
}
- (void)createSystemViewController {
NSString *nsTitle = ACETapBarItemNames[ kCRSystem ];
ICRSystemViewController *systemVCtrl = [[ICRSystemViewController alloc] init];
[m_arrTabBarBaseViewController addObject:systemVCtrl];
systemVCtrl.title = [IBTCommon localizableString:nsTitle];
IBTUINavigationController *navCtrl = [[IBTUINavigationController alloc] initWithRootViewController:systemVCtrl];
[m_arrViewController addObject:navCtrl];
navCtrl.title = nsTitle;
}
@end
//
// ICRHTTPController.h
// Cruiser
//
// Created by Xummer on 3/26/15.
// Copyright (c) 2015 Xummer. All rights reserved.
//
#import "IBTObject.h"
@interface ICRHTTPController : IBTObject
+ (instancetype)sharedController;
// Restful API
// User
- (void)doLoginWithUserName:(NSString *)userName
password:(NSString *)password
registerCode:(NSString *)registerCode
success:(void (^)(id data))succ
failure:(void (^)(id data))fail;
- (void)doChangePassword:(NSString *)nsPassword
newPassword:(NSString *)nsNewPassword
success:(void (^)(id data))succ
failure:(void (^)(id data))fail;
//
@end
This diff is collapsed.
//
// Cruiser-Prefix.pch
// Cruiser
//
// Created by Xummer on 3/23/15.
// Copyright (c) 2015 Xummer. All rights reserved.
//
#ifndef Cruiser_Cruiser_Prefix_pch
#define Cruiser_Cruiser_Prefix_pch
// Include any system framework and library headers here that should be included in all compilation units.
// You will also need to set the Prefix Header build setting of one or more of your targets to reference this file.
#import "IBTConstants.h"
#import "ICRAppMacro.h"
#endif
//
// NSDate+FormatterAdditions.h
// JobTalk
//
// Created by Xummer on 14-5-16.
// Copyright (c) 2014年 BST. All rights reserved.
//
#import <Foundation/Foundation.h>
// https://github.com/samsoffes/sstoolkit/blob/master/SSToolkit/NSDate%2BSSToolkitAdditions.h
/**
Provides extensions to `NSDate` for various common tasks.
*/
@interface NSDate (FormatterAdditions)
///---------------
/// @name ISO 8601
///---------------
/**
Returns a new date represented by an ISO8601 string.
@param iso8601String An ISO8601 string
@return Date represented by the ISO8601 string
*/
+ (NSDate *)dateFromISO8601String:(NSString *)iso8601String;
/**
Returns a string representation of the receiver in ISO8601 format.
@return A string representation of the receiver in ISO8601 format.
*/
- (NSString *)ISO8601String;
/**
@param dateFormatter a date formatter, like @"%Y-%m-%dT%H:%M:%SZ".
@return A string representation of the receiver in dateFormatter.
*/
- (NSString *)stringWithFormatter:(NSString *)dateFormatter;
- (NSString *)chatAttachmentFormatterString;
- (NSString *)chatMsgFormatterString;
- (NSString *)localYMDString;
- (NSString *)briefTimeForTimeLine;
- (NSDate *)endOfTheDay;
///--------------------
/// @name Time In Words
///--------------------
/**
Returns a string representing the time interval from now in words (including seconds).
The strings produced by this method will be similar to produced by Twitter for iPhone or Tweetbot in the top right of
the tweet cells.
Internally, this does not use `timeInWordsFromTimeInterval:includingSeconds:`.
@return A string representing the time interval from now in words
*/
- (NSString *)briefTimeInWords;
/**
Returns a string representing the time interval from now in words (including seconds).
The strings produced by this method will be similar to produced by ActiveSupport's `time_ago_in_words` helper method.
@return A string representing the time interval from now in words
@see timeInWordsIncludingSeconds:
@see timeInWordsFromTimeInterval:includingSeconds:
*/
- (NSString *)timeInWords;
/**
Returns a string representing the time interval from now in words.
The strings produced by this method will be similar to produced by ActiveSupport's `time_ago_in_words` helper method.
@param includeSeconds `YES` if seconds should be included. `NO` if they should not.
@return A string representing the time interval from now in words
@see timeInWordsIncludingSeconds:
@see timeInWordsFromTimeInterval:includingSeconds:
*/
- (NSString *)timeInWordsIncludingSeconds:(BOOL)includeSeconds;
/**
Returns a string representing a time interval in words.
The strings produced by this method will be similar to produced by ActiveSupport's `time_ago_in_words` helper method.
@param intervalInSeconds The time interval to convert to a string
@param includeSeconds `YES` if seconds should be included. `NO` if they should not.
@return A string representing the time interval in words
@see timeInWords
@see timeInWordsIncludingSeconds:
*/
+ (NSString *)timeInWordsFromTimeInterval:(NSTimeInterval)intervalInSeconds includingSeconds:(BOOL)includeSeconds;
@end
@interface NSDate (DateFormatterAdditions)
- (NSString *)timeStampStr;
+ (NSString *)curTimeStamp;
@end
@interface NSNumber (DateFormatterAdditions)
- (NSDate *)dateValue;
- (NSDate *)overZeroDateValue;
@end
@interface NSString (DateFormatterAdditions)
- (NSTimeInterval)timeStamp;
- (NSDate *)dateValue;
- (NSDate *)overZeroDateValue;
@end
This diff is collapsed.
//
// Created by kazuma.ukyo on 12/27/12.
//
// To change the template use AppCode | Preferences | File Templates.
//
#import <Foundation/Foundation.h>
// http://stackoverflow.com/questions/2060741/does-objective-c-use-short-circuit-evaluation
@interface NSNull (OVNatural)
- (void)forwardInvocation:(NSInvocation *)anInvocation;
- (NSMethodSignature *)methodSignatureForSelector:(SEL)aSelector;
@end
//
// Created by kazuma.ukyo on 12/27/12.
//
// To change the template use AppCode | Preferences | File Templates.
//
#import "NSNull+OVNatural.h"
@implementation NSNull (OVNatural)
- (void)forwardInvocation:(NSInvocation *)invocation
{
if ([self respondsToSelector:[invocation selector]]) {
[invocation invokeWithTarget:self];
}
}
- (NSMethodSignature *)methodSignatureForSelector:(SEL)selector
{
NSMethodSignature *sig = [[NSNull class] instanceMethodSignatureForSelector:selector];
if(sig == nil) {
sig = [NSMethodSignature signatureWithObjCTypes:"@^v^c"];
}
return sig;
}
@end
//
// NSString+TrimmingAdditions.h
// JobTalk
//
// Created by Xummer on 14-9-28.
// Copyright (c) 2014年 BST. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface NSString (TrimmingAdditions)
- (NSString *)stringByTrimmingLeadingCharactersInSet:(NSCharacterSet *)characterSet;
- (NSString *)stringByTrimmingLeadingWhitespaceAndNewlineCharacters;
- (NSString *)stringByTrimmingTrailingCharactersInSet:(NSCharacterSet *)characterSet;
- (NSString *)stringByTrimmingTrailingWhitespaceAndNewlineCharacters;
@end
@interface NSString (Segmentation)
- (NSString *)UserIDFromJidStr;
- (NSString *)JidStrWithUserID;
@end
@interface NSString (EncodeAndDecode)
- (NSString *)MD5String;
- (NSString *)uppercaseMD5String;
@end
\ No newline at end of file
//
// NSString+TrimmingAdditions.m
// JobTalk
//
// Created by Xummer on 14-9-28.
// Copyright (c) 2014年 BST. All rights reserved.
//
#import "NSString+TrimmingAdditions.h"
@implementation NSString (TrimmingAdditions)
- (NSString *)stringByTrimmingLeadingCharactersInSet:(NSCharacterSet *)characterSet {
NSRange rangeOfFirstWantedCharacter = [self rangeOfCharacterFromSet:[characterSet invertedSet]];
if (rangeOfFirstWantedCharacter.location == NSNotFound) {
return @"";
}
return [self substringFromIndex:rangeOfFirstWantedCharacter.location];
}
- (NSString *)stringByTrimmingLeadingWhitespaceAndNewlineCharacters {
return [self stringByTrimmingLeadingCharactersInSet:
[NSCharacterSet whitespaceAndNewlineCharacterSet]];
}
- (NSString *)stringByTrimmingTrailingCharactersInSet:(NSCharacterSet *)characterSet {
NSRange rangeOfLastWantedCharacter = [self rangeOfCharacterFromSet:[characterSet invertedSet]
options:NSBackwardsSearch];
if (rangeOfLastWantedCharacter.location == NSNotFound) {
return @"";
}
return [self substringToIndex:rangeOfLastWantedCharacter.location+1]; // non-inclusive
}
- (NSString *)stringByTrimmingTrailingWhitespaceAndNewlineCharacters {
return [self stringByTrimmingTrailingCharactersInSet:
[NSCharacterSet whitespaceAndNewlineCharacterSet]];
}
@end
#import <CommonCrypto/CommonDigest.h>
@implementation NSString (EncodeAndDecode)
- (NSString *)MD5String {
// Create pointer to the string as UTF8
const char *ptr = [self UTF8String];
// Create byte array of unsigned chars
unsigned char md5Buffer[CC_MD5_DIGEST_LENGTH];
// Create 16 byte MD5 hash value, store in buffer
CC_MD5(ptr, (CC_LONG)strlen(ptr), md5Buffer);
// Convert MD5 value in the buffer to NSString of hex values
NSMutableString *output = [NSMutableString stringWithCapacity:CC_MD5_DIGEST_LENGTH * 2];
for(int i = 0; i < CC_MD5_DIGEST_LENGTH; i++)
[output appendFormat:@"%02x",md5Buffer[i]];
return output;
}
- (NSString *)uppercaseMD5String {
return [[self MD5String] uppercaseString];
}
@end
\ No newline at end of file
//
// UIApplication+CheckFirstRun.h
// Cruiser
//
// Created by Xummer on 3/26/15.
// Copyright (c) 2015 Xummer. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface UIApplication (CheckFirstRun)
- (BOOL)isFirstRun;
- (BOOL)isFirstRunCurrentVersion;
- (void)setFirstRun;
- (void)setNotFirstRun;
- (float)version;
@end
//
// UIApplication+CheckFirstRun.m
// Cruiser
//
// Created by Xummer on 3/26/15.
// Copyright (c) 2015 Xummer. All rights reserved.
//
#import "UIApplication+CheckFirstRun.h"
@implementation UIApplication (CheckFirstRun)
- (BOOL)isFirstRun{
return [[NSUserDefaults standardUserDefaults] valueForKey:@"version"] == nil;
}
- (BOOL)isFirstRunCurrentVersion {
if ([self isFirstRun]) {
return YES;
}
else {
return [[NSUserDefaults standardUserDefaults] floatForKey:@"version"] == [[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"] floatValue];
}
}
- (void)setFirstRun {
[[NSUserDefaults standardUserDefaults] setFloat:-1 forKey:@"version"];
[[NSUserDefaults standardUserDefaults] synchronize];
}
- (void)setNotFirstRun {
[[NSUserDefaults standardUserDefaults] setFloat:[self version] forKey:@"version"];
[[NSUserDefaults standardUserDefaults] synchronize];
}
- (float)version {
return [[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"] floatValue];
}
@end
//
// UIColor+Helper.h
// SAO
//
// Created by Xummer on 14-3-20.
// Copyright (c) 2014年 Xummer. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface UIColor (Helper)
// Input float color value without /255.0f
+ (UIColor *)colorWithR:(CGFloat)red g:(CGFloat)green b:(CGFloat)blue a:(CGFloat)alpha;
+ (UIColor *)colorWithW:(CGFloat)white a:(CGFloat)alpha;
/**
colorFromHex
@param rgbValue please input like 0xFF1226
@returns color from rgbValue
*/
+ (UIColor *)colorFromHex:(int32_t)rgbValue;
@end
//
// UIColor+Helper.m
// SAO
//
// Created by Xummer on 14-3-20.
// Copyright (c) 2014年 Xummer. All rights reserved.
//
#import "UIColor+Helper.h"
@implementation UIColor (Helper)
+ (UIColor *)colorWithR:(CGFloat)red g:(CGFloat)green b:(CGFloat)blue a:(CGFloat)alpha {
return [UIColor colorWithRed:red/255.0f green:green/255.0f blue:blue/255.0f alpha:alpha];
}
+ (UIColor *)colorWithW:(CGFloat)white a:(CGFloat)alpha {
return [UIColor colorWithWhite:white/255.0f alpha:alpha];
}
+ (UIColor *)colorFromHex:(int32_t)rgbValue {
return [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0
green:((float)((rgbValue & 0xFF00) >> 8))/255.0
blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0];
}
@end
//
// UIFont+Custom.h
// SAO
//
// Created by Xummer on 14-3-20.
// Copyright (c) 2014年 Xummer. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface UIFont (Custom)
+ (UIFont *)customFontOfSize:(CGFloat)fontSize;
+ (UIFont *)boldCustomFontOfSize:(CGFloat)fontSize;
@end
//
// UIFont+Custom.m
// SAO
//
// Created by Xummer on 14-3-20.
// Copyright (c) 2014年 Xummer. All rights reserved.
//
#import "UIFont+Custom.h"
@implementation UIFont (Custom)
+ (UIFont *)customFontOfSize:(CGFloat)fontSize {
return [UIFont fontWithName:@"SAOUITT-Regular" size:fontSize];
}
+ (UIFont *)boldCustomFontOfSize:(CGFloat)fontSize {
return [UIFont fontWithName:@"SAOUITT-Bold" size:fontSize];
}
@end
//
// UIImage+Helper.h
// CXA
//
// Created by Xummer on 14-3-3.
// Copyright (c) 2014年 Xummer. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface UIImage (Helper)
+ (UIImage *)getThumbnailImage:(UIImage *)image withMaxLen:(CGFloat)maxLen;
- (UIImage *)thumbnailWithMaxLen:(CGFloat)maxLen;
- (UIImage *)imageWithTintColor:(UIColor *)tintColor;
- (UIImage *)imageWithGradientTintColor:(UIColor *)tintColor;
- (UIImage *)imageWithTintColor:(UIColor *)tintColor blendMode:(CGBlendMode)blendMode;
@end
@interface UIImage (Color)
+ (UIImage *)imageWithColor:(UIColor *)color;
+ (UIImage *)imageWithColor:(UIColor *)color andSize:(CGSize)size;
+ (UIImage *)imageWithColor:(UIColor *)color andRect:(CGRect)rect;
- (UIImage *)greyScaleImage;
@end
//
// UIImage+Helper.m
// CXA
//
// Created by Xummer on 14-3-3.
// Copyright (c) 2014年 Xummer. All rights reserved.
//
#import "UIImage+Helper.h"
@implementation UIImage (Helper)
// if newImage's width or heigth < 1, image will be cliped
+ (UIImage *)getThumbnailImage:(UIImage *)image withMaxLen:(CGFloat)maxLen
{
CGFloat imageMaxLen, imageMinLen;
BOOL widthIsLarger = image.size.width > image.size.height;
if (widthIsLarger) {
imageMaxLen = image.size.width;
imageMinLen = image.size.height;
}
else {
imageMaxLen = image.size.height;
imageMinLen = image.size.width;
}
if (imageMaxLen > maxLen) {
CGFloat scaleFloat = maxLen/imageMaxLen;
CGFloat newImgMinL = imageMinLen * scaleFloat;
CGSize size;
if (newImgMinL < 1) {
scaleFloat = 1/imageMinLen;
if (widthIsLarger) {
size = CGSizeMake(maxLen, image.size.height * scaleFloat);
}
else {
size = CGSizeMake(image.size.width * scaleFloat, maxLen);
}
}
else {
size = CGSizeMake(image.size.width * scaleFloat,
image.size.height * scaleFloat);
}
UIGraphicsBeginImageContext(size);
CGContextRef context = UIGraphicsGetCurrentContext();
CGAffineTransform transform = CGAffineTransformIdentity;
transform = CGAffineTransformScale(transform, scaleFloat, scaleFloat);
CGContextConcatCTM(context, transform);
// Draw the image into the transformed context and return the image
[image drawAtPoint:CGPointMake(0.0f, 0.0f)];
UIImage *newimg = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return newimg;
}
else{
return image;
}
}
- (UIImage *)thumbnailWithMaxLen:(CGFloat)maxLen {
return [[self class] getThumbnailImage:self withMaxLen:maxLen];
}
- (UIImage *)imageWithTintColor:(UIColor *)tintColor {
return [self imageWithTintColor:tintColor blendMode:kCGBlendModeDestinationIn];
}
- (UIImage *)imageWithGradientTintColor:(UIColor *)tintColor {
return [self imageWithTintColor:tintColor blendMode:kCGBlendModeOverlay];
}
- (UIImage *)imageWithTintColor:(UIColor *)tintColor blendMode:(CGBlendMode)blendMode
{
//We want to keep alpha, set opaque to NO; Use 0.0f for scale to use the scale factor of the device’s main screen.
UIGraphicsBeginImageContextWithOptions(self.size, NO, 0.0f);
[tintColor setFill];
CGRect bounds = CGRectMake(0, 0, self.size.width, self.size.height);
UIRectFill(bounds);
//Draw the tinted image in context
[self drawInRect:bounds blendMode:blendMode alpha:1.0f];
if (blendMode != kCGBlendModeDestinationIn) {
[self drawInRect:bounds blendMode:kCGBlendModeDestinationIn alpha:1.0f];
}
UIImage *tintedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return tintedImage;
}
@end
@implementation UIImage (Color)
typedef enum {
ALPHA = 0,
BLUE = 1,
GREEN = 2,
RED = 3
} PIXELS;
+ (UIImage *)imageWithColor:(UIColor *)color {
CGRect rect = CGRectMake(0.0f,0.0f,1.0f,1.0f);
return [[self class] imageWithColor:color andRect:rect];
}
+ (UIImage *)imageWithColor:(UIColor *)color andRect:(CGRect)rect {
UIGraphicsBeginImageContext(rect.size);
CGContextRef context =UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context,[color CGColor]);
CGContextFillRect(context, rect);
UIImage *image =UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
+ (UIImage *)imageWithColor:(UIColor *)color andSize:(CGSize)size {
return [[self class] imageWithColor:color andRect:(CGRect){
.origin = CGPointZero,
.size = size
}];
}
- (UIImage *)greyScaleImage {
CGSize size = [self size];
int width = size.width;
int height = size.height;
// the pixels will be painted to this array
uint32_t *pixels = (uint32_t *) malloc(width * height * sizeof(uint32_t));
// clear the pixels so any transparency is preserved
memset(pixels, 0, width * height * sizeof(uint32_t));
CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
// create a context with RGBA pixels
CGContextRef context = CGBitmapContextCreate(pixels, width, height, 8, width * sizeof(uint32_t), colorSpace,
kCGBitmapByteOrder32Little | kCGImageAlphaPremultipliedLast);
// paint the bitmap to our context which will fill in the pixels array
CGContextDrawImage(context, CGRectMake(0, 0, width, height), [self CGImage]);
for(int y = 0; y < height; y++) {
for(int x = 0; x < width; x++) {
uint8_t *rgbaPixel = (uint8_t *) &pixels[y * width + x];
// convert to grayscale using recommended method: http://en.wikipedia.org/wiki/Grayscale#Converting_color_to_grayscale
uint32_t gray = 0.3 * rgbaPixel[RED] + 0.59 * rgbaPixel[GREEN] + 0.11 * rgbaPixel[BLUE];
// set the pixels to gray
rgbaPixel[RED] = gray;
rgbaPixel[GREEN] = gray;
rgbaPixel[BLUE] = gray;
}
}
// create a new CGImageRef from our context with the modified pixels
CGImageRef image = CGBitmapContextCreateImage(context);
// we're done with the context, color space, and pixels
CGContextRelease(context);
CGColorSpaceRelease(colorSpace);
free(pixels);
// make a new UIImage to return
UIImage *resultUIImage = [UIImage imageWithCGImage:image];
// we're done with image now too
CGImageRelease(image);
return resultUIImage;
}
@end
//
// UILabel+SizeCalculate.h
//
//
// Created by Xummer on 14-2-19.
// Copyright (c) 2014年 Xummer. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface UILabel (SizeCalculate)
+ (CGFloat)getLabelWidth:(UILabel *)label;
+ (CGFloat)getLabelHeight:(UILabel *)label;
+ (CGSize)getLabelSize:(UILabel *)label;
+ (CGSize)getSizeWithText:(NSString *)text font:(UIFont *)font andSize:(CGSize)size;
+ (CGSize)getSizeWithText:(NSString *)text font:(UIFont *)font andWidth:(CGFloat)width;
+ (CGFloat)getHeightWithText:(NSString *)text font:(UIFont *)font andWidth:(CGFloat)width;
+ (CGFloat)getWidthWithText:(NSString *)text font:(UIFont *)font andHeight:(CGFloat)height;
- (CGFloat)calculateWidth;
- (CGFloat)calculateHeight;
- (CGSize)calculateSize;
@end
//
// UILabel+SizeCalculate.m
//
//
// Created by Xummer on 14-2-19.
// Copyright (c) 2014年 Xummer. All rights reserved.
//
#import "UILabel+SizeCalculate.h"
@implementation UILabel (SizeCalculate)
+ (CGSize)getSizeWithText:(NSString *)text font:(UIFont *)font andSize:(CGSize)size {
CGSize expectedLabelSize = CGSizeZero;
if (!font || !text ) {
return expectedLabelSize;
}
if (IBT_IOS7_OR_LATER) {
NSDictionary *stringAttributes = @{ NSFontAttributeName : font };
expectedLabelSize =
[text boundingRectWithSize:size
options:NSStringDrawingTruncatesLastVisibleLine|NSStringDrawingUsesLineFragmentOrigin
attributes:stringAttributes
context:nil].size;
}
else {
expectedLabelSize =
[text sizeWithFont:font
constrainedToSize:size
lineBreakMode:NSLineBreakByWordWrapping];
}
return expectedLabelSize;
}
+ (CGSize)getSizeWithText:(NSString *)text font:(UIFont *)font andWidth:(CGFloat)width {
return [[self class] getSizeWithText:text
font:font
andSize:CGSizeMake(width, MAXFLOAT)];
}
+ (CGFloat)getWidthWithText:(NSString *)text font:(UIFont *)font andHeight:(CGFloat)height {
CGSize expectedLabelSize = CGSizeZero;
if (IBT_IOS7_OR_LATER) {
NSDictionary *stringAttributes = @{ NSFontAttributeName : font };
expectedLabelSize =
[text boundingRectWithSize:CGSizeMake(MAXFLOAT, height)
options:NSStringDrawingTruncatesLastVisibleLine|NSStringDrawingUsesLineFragmentOrigin
attributes:stringAttributes
context:nil].size;
}
else {
expectedLabelSize =
[text sizeWithFont:font
constrainedToSize:CGSizeMake(MAXFLOAT, height)
lineBreakMode:NSLineBreakByWordWrapping];
}
return ceil(expectedLabelSize.width);
}
+ (CGFloat)getLabelWidth:(UILabel *)label {
return [[self class] getWidthWithText:label.text
font:label.font
andHeight:CGRectGetHeight(label.frame)];
}
+ (CGFloat)getLabelHeight:(UILabel *)label {
return [[self class] getHeightWithText:label.text
font:label.font
andWidth:label.frame.size.width];
}
+ (CGSize)getLabelSize:(UILabel *)label {
return [[self class] getSizeWithText:label.text
font:label.font
andWidth:CGRectGetWidth(label.frame)];
}
+ (CGFloat)getHeightWithText:(NSString *)text font:(UIFont *)font andWidth:(CGFloat)width {
return ceil([[self class] getSizeWithText:text
font:font
andWidth:width].height);
}
- (CGFloat)calculateWidth {
return [[self class] getLabelWidth:self];
}
- (CGFloat)calculateHeight {
return [[self class] getLabelHeight:self];
}
- (CGSize)calculateSize {
return [[self class] getLabelSize:self];
}
@end
//
// UIResponder+FirstResponder.h
// JobTalk
//
// Created by Xummer on 14/12/18.
// Copyright (c) 2014年 BST. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface UIResponder (FirstResponder)
+ (id)currentFirstResponder;
@end
//
// UIResponder+FirstResponder.m
// JobTalk
//
// Created by Xummer on 14/12/18.
// Copyright (c) 2014年 BST. All rights reserved.
//
#import "UIResponder+FirstResponder.h"
static __weak id currentFirstResponder;
@implementation UIResponder (FirstResponder)
+ (id)currentFirstResponder {
currentFirstResponder = nil;
[[UIApplication sharedApplication] sendAction:@selector(findFirstResponder:) to:nil from:nil forEvent:nil];
return currentFirstResponder;
}
- (void)findFirstResponder:(id)sender {
currentFirstResponder = self;
}
@end
//
// UITabBarItem+Universal.h
// AceMTer
//
// Created by Xummer on 2/27/15.
// Copyright (c) 2015 Xummer. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface UITabBarItem (Universal)
+ (instancetype)itemWithTitle:(NSString *)title
image:(UIImage *)image
selectedImage:(UIImage *)selectedImage;
@end
//
// UITabBarItem+Universal.m
// AceMTer
//
// Created by Xummer on 2/27/15.
// Copyright (c) 2015 Xummer. All rights reserved.
//
#import "UITabBarItem+Universal.h"
@implementation UITabBarItem (Universal)
+ (instancetype)itemWithTitle:(NSString *)title
image:(UIImage *)image
selectedImage:(UIImage *)selectedImage
{
UITabBarItem *tabBarItem = nil;
if (IBT_IOS7_OR_LATER) {
tabBarItem = [[UITabBarItem alloc] initWithTitle:title image:image selectedImage:selectedImage];
}
else {
tabBarItem = [[UITabBarItem alloc] initWithTitle:title image:nil tag:0];
[tabBarItem setFinishedSelectedImage:selectedImage withFinishedUnselectedImage:image];
}
return tabBarItem;
}
@end
//
// UITableViewCell+Helper.h
// CXA
//
// Created by Xummer on 14-3-19.
// Copyright (c) 2014年 Xummer. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface UITableViewCell (Helper)
+ (UINib *)nib;
+ (id)cellFromNib;
+ (CGFloat)getCellHeight;
+ (NSString *)reuseIdentifier;
@end
//
// UITableViewCell+Helper.m
// CXA
//
// Created by Xummer on 14-3-19.
// Copyright (c) 2014年 Xummer. All rights reserved.
//
#import "UITableViewCell+Helper.h"
@implementation UITableViewCell (Helper)
+ (UINib *)nib {
return [UINib nibWithNibName:NSStringFromClass([self class]) bundle:nil];
}
+ (id)cellFromNib {
NSArray *array =
[[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class])
owner:self
options:nil];
return [array firstObject];
}
+ (CGFloat)getCellHeight {
UITableViewCell *cell = [[self class] cellFromNib];
return CGRectGetHeight(cell.frame);
}
+ (NSString *)reuseIdentifier {
return NSStringFromClass([self class]);
}
@end
//
// UIView+FindUIViewController.h
// JobTalk
//
// Created by Xummer on 1/20/15.
// Copyright (c) 2015 BST. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
@interface UIView (FindUIViewController)
- (UIViewController *)firstAvailableUIViewController;
- (id)traverseResponderChainForUIViewController;
@end
@interface UIView (Extend)
- (NSArray *)subviewsWithClass:(Class)aClass;
- (id)viewWithClass:(Class)aClass;
- (void)removeSubViewWithClass:(Class)aClass;
- (void)removeSubViewWithTag:(NSInteger)tag;
- (void)removeAllSubViews;
- (void)autoresizingWithStrechFullSize;
- (void)autoresizingWithVerticalCenter;
- (void)autoresizingWithHorizontalCenter;
@end
//
// UIView+FindUIViewController.m
// JobTalk
//
// Created by Xummer on 1/20/15.
// Copyright (c) 2015 BST. All rights reserved.
//
#import "UIView+FindUIViewController.h"
@implementation UIView (FindUIViewController)
- (UIViewController *)firstAvailableUIViewController {
// convenience function for casting and to "mask" the recursive function
return (UIViewController *)[self traverseResponderChainForUIViewController];
}
- (id)traverseResponderChainForUIViewController {
id nextResponder = [self nextResponder];
if ([nextResponder isKindOfClass:[UIViewController class]]) {
return nextResponder;
}
else if ([nextResponder isKindOfClass:[UIView class]]) {
return [nextResponder traverseResponderChainForUIViewController];
}
else {
return nil;
}
}
@end
@implementation UIView (Extend)
- (NSArray *)subviewsWithClass:(Class)aClass {
NSMutableArray *arrTmp = [NSMutableArray array];
for (UIView *view in self.subviews) {
if ([view isKindOfClass:aClass]) {
[arrTmp addObject:view];
}
}
return [arrTmp count] > 0 ? arrTmp : nil;
}
- (id)viewWithClass:(Class)aClass {
__block id machedView = nil;
[self.subviews enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
if ([obj isKindOfClass:aClass]) {
machedView = obj;
*stop = YES;
}
}];
return machedView;
}
- (void)removeSubViewWithClass:(Class)aClass {
[[self viewWithClass:aClass] removeFromSuperview];
}
- (void)removeSubViewWithTag:(NSInteger)tag {
[[self viewWithTag:tag] removeFromSuperview];
}
- (void)removeAllSubViews {
[self.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
}
- (void)autoresizingWithStrechFullSize {
self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
}
- (void)autoresizingWithVerticalCenter {
self.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin;
}
- (void)autoresizingWithHorizontalCenter {
self.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
}
@end
//
// UIView+ViewFrameGeometry.h
// IBTTableViewKit
//
// Created by Xummer on 15/1/9.
// Copyright (c) 2015年 Xummer. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface UIView (ViewFrameGeometry)
@property (assign) CGFloat x;
@property (assign) CGFloat y;
@property (assign) CGFloat width;
@property (assign) CGFloat height;
@property (assign) CGSize size;
@property (assign) CGPoint origin;
@property (assign) CGFloat left;
@property (assign) CGFloat right;
@property (assign) CGFloat top;
@property (assign) CGFloat bottom;
@property (readonly, assign) CGPoint topRight;
@property (readonly, assign) CGPoint bottomRight;
@property (readonly, assign) CGPoint bottomLeft;
//- (void)frameIntegral;
//- (void)ceilAllSubviews;
//- (void)fitTheSubviews;
- (void)fitInSize:(CGSize)aSize;
- (void)scaleBy:(CGFloat)fScaleFactor;
- (void)moveBy:(CGPoint)pDelta;
- (CGSize)widthLimitedSizeThatFits:(CGSize)size;
- (CGSize)heightLimitedSizeThatFits:(CGSize)size;
@end
//
// UIView+ViewFrameGeometry.m
// IBTTableViewKit
//
// Created by Xummer on 15/1/9.
// Copyright (c) 2015年 Xummer. All rights reserved.
//
#import "UIView+ViewFrameGeometry.h"
@implementation UIView (ViewFrameGeometry)
- (CGFloat) x {
return self.frame.origin.x;
}
- (void) setX:(CGFloat)x {
CGRect nframe = self.frame;
nframe.origin.x = x;
self.frame = nframe;
}
- (CGFloat) y {
return self.frame.origin.y;
}
- (void) setY:(CGFloat)y {
CGRect nframe = self.frame;
nframe.origin.y = y;
self.frame = nframe;
}
// Retrieve and set height, width
- (CGFloat) width {
return self.frame.size.width;
}
- (void) setWidth:(CGFloat)width {
CGRect nframe = self.frame;
nframe.size.width = width;
self.frame = nframe;
}
- (CGFloat) height {
return self.frame.size.height;
}
- (void) setHeight:(CGFloat)height {
CGRect nframe = self.frame;
nframe.size.height = height;
self.frame = nframe;
}
// Retrieve and set the origin, size
- (CGPoint) origin {
return self.frame.origin;
}
- (void) setOrigin:(CGPoint)aPoint {
CGRect nframe = self.frame;
nframe.origin = aPoint;
self.frame = nframe;
}
- (CGSize) size {
return self.frame.size;
}
- (void) setSize:(CGSize)aSize {
CGRect nframe = self.frame;
nframe.size = aSize;
self.frame = nframe;
}
// Retrieve and set top, bottom, left, right
- (CGFloat) left {
return self.x;
}
- (void) setLeft:(CGFloat)left {
self.x = left;
}
- (CGFloat) right {
return CGRectGetMaxX(self.frame);
}
- (void) setRight:(CGFloat)right {
self.x = right - self.width;
}
- (CGFloat) top {
return self.y;
}
- (void) setTop:(CGFloat)top {
self.y = top;
}
- (CGFloat) bottom {
return CGRectGetMaxY(self.frame);
}
- (void) setBottom:(CGFloat)bottom {
self.y = bottom - self.height;
}
// Query other frame locations
- (CGPoint) topRight {
return CGPointMake(self.right, self.top);
}
- (CGPoint) bottomRight {
return CGPointMake(self.right, self.bottom);
}
- (CGPoint) bottomLeft {
return CGPointMake(self.left, self.bottom);
}
// Move via offset
- (void) moveBy:(CGPoint)delta
{
CGPoint nCenter = self.center;
nCenter.x += delta.x;
nCenter.y += delta.y;
self.center = nCenter;
}
// Scaling
- (void) scaleBy:(CGFloat)scaleFactor {
CGRect nframe = self.frame;
nframe.size.width *= scaleFactor;
nframe.size.height *= scaleFactor;
self.frame = nframe;
}
// Ensure that both dimensions fit within the given size by scaling down
- (void) fitInSize:(CGSize)aSize {
CGFloat scale;
CGRect nframe = self.frame;
if (nframe.size.height && (nframe.size.height > aSize.height)) {
scale = aSize.height / nframe.size.height;
nframe.size.width *= scale;
nframe.size.height *= scale;
}
if (nframe.size.width && (nframe.size.width >= aSize.width)) {
scale = aSize.width / nframe.size.width;
nframe.size.width *= scale;
nframe.size.height *= scale;
}
self.frame = nframe;
}
- (CGSize) widthLimitedSizeThatFits:(CGSize)size {
CGSize mSize = [self sizeThatFits:size];
if (mSize.width > size.width) {
mSize.width = size.width;
}
return mSize;
}
- (CGSize) heightLimitedSizeThatFits:(CGSize)size {
CGSize mSize = [self sizeThatFits:size];
if (mSize.height > size.height) {
mSize.height = size.height;
}
return mSize;
}
@end
//
// IBTAdditionsObserver.h
// Cruiser
//
// Created by Xummer on 3/26/15.
// Copyright (c) 2015 Xummer. All rights reserved.
//
#import "IBTObject.h"
@interface IBTAdditionsObserver : IBTObject
+ (IBTAdditionsObserver *)sharedInstance;
@end
//
// IBTAdditionsObserver.m
// Cruiser
//
// Created by Xummer on 3/26/15.
// Copyright (c) 2015 Xummer. All rights reserved.
//
#import "IBTAdditionsObserver.h"
#import "UIApplication+CheckFirstRun.h"
static IBTAdditionsObserver *sSharedInstance;
@implementation IBTAdditionsObserver
+ (void)load {
[self performSelectorOnMainThread:@selector(sharedInstance)
withObject:nil waitUntilDone:NO];
}
+ (IBTAdditionsObserver *)sharedInstance {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
sSharedInstance = [[IBTAdditionsObserver alloc] init];
});
return sSharedInstance;
}
- (id)init {
self = [super init];
if (self) {
NSNotificationCenter *notiCenter = [NSNotificationCenter defaultCenter];
[notiCenter addObserver:self
selector:@selector(AppWillTerminate)
name:UIApplicationWillResignActiveNotification
object:nil];
}
return self;
}
- (void)AppWillTerminate {
[[UIApplication sharedApplication] setNotFirstRun];
}
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
@end
//
// ICRBaseViewController.h
// Cruiser
//
// Created by Xummer on 3/22/15.
// Copyright (c) 2015 Xummer. All rights reserved.
//
#import "IBTUIViewController.h"
@interface ICRBaseViewController : IBTUIViewController
@end
//
// ICRBaseViewController.m
// Cruiser
//
// Created by Xummer on 3/22/15.
// Copyright (c) 2015 Xummer. All rights reserved.
//
#import "ICRBaseViewController.h"
@interface ICRBaseViewController ()
@end
@implementation ICRBaseViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end
//
// ICRUIAppearance.h
// Cruiser
//
// Created by Xummer on 3/31/15.
// Copyright (c) 2015 Xummer. All rights reserved.
//
#import "IBTObject.h"
@interface ICRUIAppearance : IBTObject
+ (void)CustomAppearance;
+ (void)customNavigationbarAppearance;
@end
//
// ICRUIAppearance.m
// Cruiser
//
// Created by Xummer on 3/31/15.
// Copyright (c) 2015 Xummer. All rights reserved.
//
#import "ICRUIAppearance.h"
@implementation ICRUIAppearance
+ (void)CustomAppearance {
if (IBT_IOS7_OR_LATER) {//版本大于7.0
UIApplication.sharedApplication.delegate.window.tintColor = ICR_TINTCOLOR;
}
[[self class] customNavigationbarAppearance];
}
+ (void)customNavigationbarAppearance {
[UINavigationBar appearance].barTintColor = ICR_TINTCOLOR;
[UINavigationBar appearance].tintColor = ICR_NAVIBAR_ITEM_COLOR;
//Universal
NSShadow *shadow = [[NSShadow alloc] init];
shadow.shadowOffset = CGSizeZero;
[[UINavigationBar appearance] setTitleTextAttributes:
@{ NSForegroundColorAttributeName: ICR_NAVIBAR_TITLE_COLOR,
NSFontAttributeName: [UIFont boldSystemFontOfSize:20],
NSShadowAttributeName: shadow}];
}
@end
//
// ICRCheckBox.h
// Cruiser
//
// Created by Xummer on 15/3/30.
// Copyright (c) 2015年 Xummer. All rights reserved.
//
#import "IBTUIView.h"
#define CHECK_BOX_DEFAULT_WIDTH (22.0f)
@interface ICRCheckBox : IBTUIView
@property (assign, nonatomic) BOOL isSelected;
@end
//
// ICRCheckBox.m
// Cruiser
//
// Created by Xummer on 15/3/30.
// Copyright (c) 2015年 Xummer. All rights reserved.
//
#import "ICRCheckBox.h"
@interface ICRCheckBox ()
@property (strong, nonatomic) UIButton *m_checkBoxBtn;
@property (strong, nonatomic) UIImageView *m_checkBoxBG;
@end
@implementation ICRCheckBox
#pragma mark - Life Cycle
- (instancetype)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (!self) {
return nil;
}
[self initSubviews];
return self;
}
- (void)layoutSubviews {
[super layoutSubviews];
_m_checkBoxBG.origin = (CGPoint){
.x = (self.width - _m_checkBoxBG.width) * .5f,
.y = (self.height - _m_checkBoxBG.height) * .5f
};
_m_checkBoxBtn.frame = self.bounds;
}
#pragma mark - Setter
- (void)setIsSelected:(BOOL)isSelected {
if (_isSelected == isSelected) {
return;
}
_isSelected = isSelected;
_m_checkBoxBtn.selected = _isSelected;
}
#pragma mark - Private Method
- (void)initSubviews {
self.m_checkBoxBG = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"LoginCheckBox"]];
[self addSubview:_m_checkBoxBG];
self.m_checkBoxBtn = [IBTUIButton buttonWithType:UIButtonTypeCustom];
[self.m_checkBoxBtn setImage:[UIImage imageNamed:@"LoginCheckMark"]
forState:UIControlStateSelected];
[self.m_checkBoxBtn addTarget:self
action:@selector(onCheckBoxAction:)
forControlEvents:UIControlEventTouchUpInside];
[self addSubview:_m_checkBoxBtn];
}
#pragma mark - Actions
- (void)onCheckBoxAction:(id)sender {
self.isSelected = !_isSelected;
}
@end
//
// ICRLoginContentView.h
// Cruiser
//
// Created by Xummer on 3/30/15.
// Copyright (c) 2015 Xummer. All rights reserved.
//
#import <UIKit/UIKit.h>
@class ICRCheckBox;
@interface ICRLoginContentView : UIView
@property (strong, nonatomic) UITextField *m_cCodeTextF;
@property (strong, nonatomic) UITextField *m_userNameTextF;
@property (strong, nonatomic) UITextField *m_passwordTextF;
@property (strong, nonatomic) ICRCheckBox *m_autoLoginCheckBox;
@property (strong, nonatomic) UIButton *m_loginBtn;
- (instancetype)initWithFrame:(CGRect)frame
showCCode:(BOOL)bNeedShowCCode;
- (void)checkLoginEnable;
- (BOOL)isAutoLogin;
@end
//
// ICRLoginContentView.m
// Cruiser
//
// Created by Xummer on 3/30/15.
// Copyright (c) 2015 Xummer. All rights reserved.
//
#import "ICRLoginContentView.h"
#import "ICRCheckBox.h"
#define LOGIN_ICON_WIDTH (60)
#define LOGIN_INNER_GAP (20)
#define LOGIN_INPUT_HEIGHT (50)
#define LOGIN_LABEL_MARGIN (10)
@interface ICRLoginContentView ()
{
BOOL m_bShowCode;
}
@property (strong, nonatomic) UIImageView *m_iconView;
@property (strong, nonatomic) UILabel *m_titleLabel;
@property (strong, nonatomic) UIView *m_cCodeView;
@property (strong, nonatomic) UIView *m_userNameView;
@property (strong, nonatomic) UIView *m_passwordView;
@property (strong, nonatomic) UIView *m_checkBoxView;
@end
@implementation ICRLoginContentView
#pragma mark - Class Method
+ (UIView *)TextFWithLeftLabel:(NSString *)nsLeftLabel
textF:(UITextField * __autoreleasing *)textFPointer
{
UIView *v = [[UIView alloc] init];
v.backgroundColor = [UIColor clearColor];
UIImageView *txtFBG = [[UIImageView alloc] initWithFrame:v.bounds];
txtFBG.userInteractionEnabled = YES;
txtFBG.image =
[[UIImage imageNamed:@"LoginInputBG"] stretchableImageWithLeftCapWidth:10
topCapHeight:25];
[txtFBG autoresizingWithStrechFullSize];
[v addSubview:txtFBG];
IBTUILabel *leftLabel = [[IBTUILabel alloc] init];
leftLabel.font = [UIFont systemFontOfSize:16];
leftLabel.text = nsLeftLabel;
[leftLabel sizeToFit];
leftLabel.x = LOGIN_LABEL_MARGIN;
UIView *labelContainer = [[UIView alloc] init];
labelContainer.backgroundColor = [UIColor clearColor];
labelContainer.frame = (CGRect){
.origin.x = 0,
.origin.y = 0,
.size.width = leftLabel.width + 2 * LOGIN_LABEL_MARGIN,
.size.height = leftLabel.height
};
[labelContainer addSubview:leftLabel];
UITextField *txtF = [[UITextField alloc] initWithFrame:txtFBG.bounds];
txtF.leftViewMode = UITextFieldViewModeAlways;
txtF.leftView = labelContainer;
[txtF autoresizingWithStrechFullSize];
[v addSubview:txtF];
if (textFPointer) {
*textFPointer = txtF;
}
return v;
}
#pragma mark - Life Cycle
- (instancetype)initWithFrame:(CGRect)frame
showCCode:(BOOL)bNeedShowCCode
{
self = [self initWithFrame:frame];
if (!self) {
return nil;
}
m_bShowCode = bNeedShowCCode;
return self;
}
- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (!self) {
return nil;
}
[self initSubviews];
return self;
}
- (void)layoutSubviews {
[super layoutSubviews];
self.m_iconView.frame = (CGRect){
.origin.x = (self.width - LOGIN_ICON_WIDTH) * .5f,
.origin.y = 0,
.size.width = LOGIN_ICON_WIDTH,
.size.height = LOGIN_ICON_WIDTH
};
self.m_titleLabel.frame = (CGRect){
.origin.x = 0,
.origin.y = _m_iconView.bottom + 8,
.size.width = self.width,
.size.height = 25
};
self.m_cCodeView.frame = (CGRect){
.origin.x = 0,
.origin.y = _m_titleLabel.bottom + 26,
.size.width = self.width,
.size.height = LOGIN_INPUT_HEIGHT
};
self.m_userNameView.frame = (CGRect){
.origin.x = 0,
.origin.y = _m_cCodeView.bottom + LOGIN_INNER_GAP,
.size.width = self.width,
.size.height = LOGIN_INPUT_HEIGHT
};
self.m_passwordView.frame = (CGRect){
.origin.x = 0,
.origin.y = _m_userNameView.bottom + LOGIN_INNER_GAP,
.size.width = self.width,
.size.height = LOGIN_INPUT_HEIGHT
};
self.m_checkBoxView.frame = (CGRect){
.origin.x = 0,
.origin.y = _m_passwordView.bottom + LOGIN_INNER_GAP,
.size.width = self.width,
.size.height = LOGIN_INPUT_HEIGHT
};
self.m_loginBtn.frame = (CGRect){
.origin.x = 0,
.origin.y = _m_checkBoxView.bottom + LOGIN_INNER_GAP,
.size.width = self.width,
.size.height = LOGIN_INPUT_HEIGHT
};
}
- (void)didMoveToWindow {
[super didMoveToWindow];
if (self.window) {
[self checkLoginEnable];
}
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
[self endEditing:YES];
[super touchesBegan:touches withEvent:event];
}
#pragma mark - Private Method
- (void)initSubviews {
self.m_iconView = [[UIImageView alloc] init];
_m_iconView.image = [IBTCommon appIcon];
[self addSubview:_m_iconView];
self.m_titleLabel = [[IBTUILabel alloc] init];
self.m_titleLabel.font = [UIFont systemFontOfSize:19.0f];
self.m_titleLabel.textColor = [UIColor whiteColor];
self.m_titleLabel.textAlignment = NSTextAlignmentCenter;
self.m_titleLabel.text = [IBTCommon localizableString:@"Cruiser"];
[self addSubview:_m_titleLabel];
UITextField *txtF = nil;
self.m_cCodeView =
[[self class] TextFWithLeftLabel:[[IBTCommon localizableString:@"CompanyCode"] stringByAppendingString:@":"]
textF:&txtF];
self.m_cCodeTextF = txtF;
[self addSubview:_m_cCodeView];
self.m_userNameView =
[[self class] TextFWithLeftLabel:[[IBTCommon localizableString:@"User"] stringByAppendingString:@":"]
textF:&txtF];
self.m_userNameTextF = txtF;
[self addSubview:_m_userNameView];
self.m_passwordView =
[[self class] TextFWithLeftLabel:[[IBTCommon localizableString:@"Password"] stringByAppendingString:@":"]
textF:&txtF];
self.m_passwordTextF = txtF;
_m_passwordTextF.secureTextEntry = YES;
[self addSubview:_m_passwordView];
// check box
[self initCheckBox];
// button
self.m_loginBtn = [IBTUIButton RoundCornerBtnWithTitle:[IBTCommon localizableString:@"Login"] bgColor:nil];
[self.m_loginBtn setTitle:[IBTCommon localizableString:@"Login"]
forState:UIControlStateNormal];
[self addSubview:_m_loginBtn];
}
- (void)initCheckBox {
self.m_checkBoxView = [[UIView alloc] init];
self.m_checkBoxView.backgroundColor = [UIColor clearColor];
self.m_autoLoginCheckBox = [[ICRCheckBox alloc] initWithFrame:(CGRect){
.origin.x = 0,
.origin.y = (_m_checkBoxView.height - CHECK_BOX_DEFAULT_WIDTH) * .5f,
.size.width = CHECK_BOX_DEFAULT_WIDTH,
.size.height = CHECK_BOX_DEFAULT_WIDTH
}];
_m_autoLoginCheckBox.autoresizingMask = UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleBottomMargin;
_m_autoLoginCheckBox.isSelected = YES;
[_m_checkBoxView addSubview:_m_autoLoginCheckBox];
IBTUILabel *autoLoginLabel = [[IBTUILabel alloc] init];
autoLoginLabel.textAlignment = NSTextAlignmentLeft;
autoLoginLabel.textColor = [UIColor whiteColor];
autoLoginLabel.font = [UIFont systemFontOfSize:14.0f];
autoLoginLabel.text = [IBTCommon localizableString:@"AutoLogin"];
[autoLoginLabel sizeToFit];
CGFloat fDx = _m_autoLoginCheckBox.right + 10;
autoLoginLabel.frame = (CGRect){
.origin.x = fDx,
.origin.y = 0,
.size.width = autoLoginLabel.width,
.size.height = _m_checkBoxView.height
};
autoLoginLabel.autoresizingMask =
UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[_m_checkBoxView addSubview:autoLoginLabel];
IBTUIButton *autoLoginBtn = [[IBTUIButton alloc] initWithFrame:_m_checkBoxView.bounds];
autoLoginBtn.backgroundColor = [UIColor clearColor];
[autoLoginBtn autoresizingWithStrechFullSize];
[autoLoginBtn addTarget:self
action:@selector(onAutoLoginTapped:)
forControlEvents:UIControlEventTouchUpInside];
[_m_checkBoxView addSubview:autoLoginBtn];
[self addSubview:_m_checkBoxView];
}
#pragma mark - Action
- (void)onAutoLoginTapped:(__unused id)sender {
self.m_autoLoginCheckBox.isSelected = !self.m_autoLoginCheckBox.isSelected;
}
#pragma mark - Public Method
- (void)checkLoginEnable {
self.m_loginBtn.enabled = m_bShowCode ?
((_m_cCodeTextF.text.length > 0) && (_m_userNameTextF.text.length > 0) && (_m_passwordTextF.text.length > 0)) :
((_m_userNameTextF.text.length > 0) && (_m_passwordTextF.text.length > 0));
}
- (BOOL)isAutoLogin {
return self.m_autoLoginCheckBox.isSelected;
}
@end
{
"images" : [
{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "AppIcon58x58.png",
"scale" : "2x"
},
{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "AppIcon87x87.png",
"scale" : "3x"
},
{
"size" : "40x40",
"idiom" : "iphone",
"filename" : "AppIcon80x80.png",
"scale" : "2x"
},
{
"size" : "40x40",
"idiom" : "iphone",
"filename" : "AppIcon120x120.png",
"scale" : "3x"
},
{
"size" : "60x60",
"idiom" : "iphone",
"filename" : "AppIcon120x120-1.png",
"scale" : "2x"
},
{
"size" : "60x60",
"idiom" : "iphone",
"filename" : "AppIcon180x180.png",
"scale" : "3x"
},
{
"size" : "29x29",
"idiom" : "ipad",
"filename" : "AppIcon29x29.png",
"scale" : "1x"
},
{
"size" : "29x29",
"idiom" : "ipad",
"filename" : "AppIcon58x58-1.png",
"scale" : "2x"
},
{
"size" : "40x40",
"idiom" : "ipad",
"filename" : "AppIcon40x40.png",
"scale" : "1x"
},
{
"size" : "40x40",
"idiom" : "ipad",
"filename" : "AppIcon80x80-1.png",
"scale" : "2x"
},
{
"size" : "76x76",
"idiom" : "ipad",
"filename" : "AppIcon76x76.png",
"scale" : "1x"
},
{
"size" : "76x76",
"idiom" : "ipad",
"filename" : "AppIcon152x152.png",
"scale" : "2x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x",
"filename" : "LoginBG.png"
},
{
"idiom" : "universal",
"scale" : "2x",
"filename" : "LoginBG@2x.png"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x",
"filename" : "LoginCheckBox.png"
},
{
"idiom" : "universal",
"scale" : "2x",
"filename" : "LoginCheckBox@2x.png"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x",
"filename" : "LoginCheckMark.png"
},
{
"idiom" : "universal",
"scale" : "2x",
"filename" : "LoginCheckMark@2x.png"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x",
"filename" : "LoginInputBG.png"
},
{
"idiom" : "universal",
"scale" : "2x",
"filename" : "LoginInputBG@2x.png"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>Xummer.$(PRODUCT_NAME:rfc1034identifier)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>armv7</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
</dict>
</plist>
//
// ICRAppMacro.h
// Cruiser
//
// Created by Xummer on 15/3/25.
// Copyright (c) 2015年 Xummer. All rights reserved.
//
#ifndef Cruiser_ICRAppMacro_h
#define Cruiser_ICRAppMacro_h
// COLOR
#define ICR_TINTCOLOR [UIColor colorWithR:63 g:134 b:244 a:1]
#define ICR_BLUE_BTN_COLOR ICR_TINTCOLOR
#define ICR_GRAY_BTN_COLOR [UIColor lightGrayColor]
#define ICR_NAVIBAR_ITEM_COLOR [UIColor whiteColor]
#define ICR_NAVIBAR_ITEM_DISABLE_COLOR [UIColor colorWithW:1 a:.5f]
#define ICR_NAVIBAR_TITLE_COLOR [UIColor whiteColor]
// HTTP
#define HTTP_REST_API_BASE_URL @"http://115.28.191.44:8080/IPatrol/rest"
#import "ICRHTTPController.h"
#import "ICRUserUtil.h"
#import "ICRAppViewControllerManager.h"
#endif
//
// ICRNotificationMacro.h
// Cruiser
//
// Created by Xummer on 15/3/25.
// Copyright (c) 2015年 Xummer. All rights reserved.
//
#ifndef Cruiser_ICRNotificationMacro_h
#define Cruiser_ICRNotificationMacro_h
#endif
//
// ICRUtilsMacro.h
// Cruiser
//
// Created by Xummer on 15/3/25.
// Copyright (c) 2015年 Xummer. All rights reserved.
//
#ifndef Cruiser_ICRUtilsMacro_h
#define Cruiser_ICRUtilsMacro_h
#endif
//
// ICRVendorMacro.h
// Cruiser
//
// Created by Xummer on 15/3/25.
// Copyright (c) 2015年 Xummer. All rights reserved.
//
#ifndef Cruiser_ICRVendorMacro_h
#define Cruiser_ICRVendorMacro_h
#endif
//
// IBTTableViewCellInfo.h
// IBTTableViewKit
//
// Created by Xummer on 15/1/5.
// Copyright (c) 2015年 Xummer. All rights reserved.
//
#import "IBTTableViewUserInfo.h"
@class IBTTableViewCell;
@interface IBTTableViewCellInfo : IBTTableViewUserInfo
@property (weak, nonatomic) id actionTargetForSwitchCell;
//@property (assign, nonatomic) BOOL bTitleNormalFont;
//@property (assign, nonatomic) BOOL bNeedSeperateLine;
@property (weak, nonatomic) IBTTableViewCell* cell;
@property (assign, nonatomic) UITableViewCellStyle cellStyle;
@property (assign, nonatomic) UITextAutocorrectionType autoCorrectionType;
@property (assign, nonatomic) UITableViewCellEditingStyle editStyle;
@property (assign, nonatomic) UITableViewCellAccessoryType accessoryType;
@property (assign, nonatomic) UITableViewCellSelectionStyle selectionStyle;
@property (assign, nonatomic) CGFloat fCellHeight;
@property (weak, nonatomic) id calHeightTarget;
@property (assign, nonatomic) SEL calHeightSel;
@property (weak, nonatomic) id actionTarget;
@property (assign, nonatomic) SEL actionSel;
@property (weak, nonatomic) id makeTarget;
@property (assign, nonatomic) SEL makeSel;
// Normal
+ (IBTTableViewCellInfo *)normalCellForTitle:(NSString *)title rightValue:(NSString *)rightValue;
+ (IBTTableViewCellInfo *)normalCellForTitle:(NSString *)title rightValue:(NSString *)rightValue
imageName:(NSString *)imgName;
+ (IBTTableViewCellInfo *)normalCellForSel:(SEL)sel target:(id)target
title:(NSString *)title
accessoryType:(UITableViewCellAccessoryType)type;
+ (IBTTableViewCellInfo *)normalCellForSel:(SEL)sel target:(id)target
title:(NSString *)title
rightValue:(NSString *)rightValue
accessoryType:(UITableViewCellAccessoryType)type;
+ (IBTTableViewCellInfo *)normalCellForSel:(SEL)sel target:(id)target
title:(NSString *)title
rightValue:(NSString *)rightValue
imageName:(NSString *)imgName
accessoryType:(UITableViewCellAccessoryType)type;
+ (IBTTableViewCellInfo *)badgeRightCellForSel:(SEL)sel target:(id)target
title:(NSString *)title badge:(id)badge rightValue:(NSString *)rightValue
imageName:(NSString *)name;
+ (IBTTableViewCellInfo *)badgeCellForSel:(SEL)sel target:(id)target
title:(NSString *)title badge:(id)badge rightValue:(NSString *)rightValue
imageName:(NSString *)name;
+ (IBTTableViewCellInfo *)badgeCellForSel:(SEL)sel target:(id)target
title:(NSString *)title badge:(id)badge rightValue:(NSString *)rightValue;
+ (IBTTableViewCellInfo *)badgeCellForSel:(SEL)sel target:(id)target
title:(NSString *)title badge:(id)badge;
+ (IBTTableViewCellInfo *)switchCellForSel:(SEL)sel target:(id)target
title:(NSString *)title on:(BOOL)bOn;
+ (IBTTableViewCellInfo *)centerCellForSel:(SEL)sel target:(id)target
title:(NSString *)title;
// Open url Inner WebView
+ (IBTTableViewCellInfo *)urlInnerBlueCellForTitle:(NSString *)title leftValue:(NSString *)value url:(id)url;
// Open url Safari (Call open url)
+ (IBTTableViewCellInfo *)urlCellForTitle:(NSString *)title url:(id)url;
+(IBTTableViewCellInfo *)editorCellForSel:(SEL)sel target:(id)target
tip:(NSString *)tip focus:(BOOL)focus text:(NSString *)text;
+(IBTTableViewCellInfo *)editorCellForSel:(SEL)sel target:(id)target
tip:(NSString *)tip focus:(BOOL)focus autoCorrect:(BOOL)correct
text:(NSString *)text;
+(IBTTableViewCellInfo *)editorCellForSel:(SEL)sel target:(id)target
title:(NSString *)title margin:(CGFloat)margin
tip:(NSString *)tip focus:(BOOL)focus
text:(NSString *)text;
+ (IBTTableViewCellInfo *)editorCellForSel:(SEL)sel target:(id)target
title:(NSString *)title
margin:(CGFloat)margin tip:(NSString *)tip
autoCorrect:(BOOL)correct focus:(BOOL)focus
text:(NSString *)text;
- (void)makeNormalCell:(IBTTableViewCellInfo *)cellInfo;
- (void)makeSwitchCell:(IBTTableViewCellInfo *)cellInfo;
- (void)makeCenterCell:(IBTTableViewCellInfo *)cellInfo;
- (void)makeEditorCell:(IBTTableViewCellInfo *)cellInfo;
@end
#define IBT_CELL_MARGIN (15.0f)
/*
@{"title":"Friend Radar","titleFont":#'<UICTFont: 0x17df36f0> font-family: ".HelveticaNeueInterface-Regular"; font-weight: normal; font-style: normal; font-size: 16.00pt',"imageName":"add_friend_icon_reda","detail":"Quickly add friends in your vicinity"}
*/
FOUNDATION_EXPORT NSString * const CInfoTitleKey;
FOUNDATION_EXPORT NSString * const CInfoTitleFontKey;
FOUNDATION_EXPORT NSString * const CInfoTitleFontSizeKey;
FOUNDATION_EXPORT NSString * const CInfoTitleColorKey;
FOUNDATION_EXPORT NSString * const CInfoDetailKey;
FOUNDATION_EXPORT NSString * const CInfoDetailFontKey;
FOUNDATION_EXPORT NSString * const CInfoDetailFontSizeKey;
FOUNDATION_EXPORT NSString * const CInfoDetailColorKey;
FOUNDATION_EXPORT NSString * const CInfoImageNameKey;
/*
@{"imageName":"MoreMyBankCard.png","title":"Wallet","badge":"New", "badgeRight":YES}
*/
FOUNDATION_EXPORT NSString * const CInfoBadgeKey;
FOUNDATION_EXPORT NSString * const CInfoBadgeBGColorKey;
FOUNDATION_EXPORT NSString * const CInfoBadgeAlignmentRightKey;
/*
@{"title":"Settings","rightValueFontSize":"14","imageName":"MoreSetting.png","rightValue":"Unprotected"}
*/
FOUNDATION_EXPORT NSString * const CInfoRightValueKey;
FOUNDATION_EXPORT NSString * const CInfoRightValueFontKey;
FOUNDATION_EXPORT NSString * const CInfoRightValueFontSizeKey;
FOUNDATION_EXPORT NSString * const CInfoRightValueColorKey;
/*
@{"title":"Xummer0","leftValueColor":#"UIDeviceRGBColorSpace 0.341176 0.419608 0.584314 1","leftValue":"2333","url":"http://xummer26.com"}
*/
FOUNDATION_EXPORT NSString * const CInfoLeftValueKey;
FOUNDATION_EXPORT NSString * const CInfoLeftValueFontKey;
FOUNDATION_EXPORT NSString * const CInfoLeftValueFontSizeKey;
FOUNDATION_EXPORT NSString * const CInfoLeftValueColorKey;
FOUNDATION_EXPORT NSString * const CInfoURLKey;
FOUNDATION_EXPORT NSString * const CInfoSwipeAbleKey; // swipe show delete button
/*
@{"switch":#"<UISwitch: 0x17ea71d0; frame = (254 6; 51 31); layer = <CALayer: 0x17ea7260>>","title":"Sticky on Top","on":false}
*/
FOUNDATION_EXPORT NSString * const CInfoSwitchKey;
FOUNDATION_EXPORT NSString * const CInfoSwitchOnKey;
/*
@{"title":"WeChat ID","fEditorLMargin":0,"focus":true,"keyboardType":1,"editor":#"<UITextField: 0x180a6a50; frame = (108 7; 202 30); text = ''; clipsToBounds = YES; opaque = NO; autoresize = W; gestureRecognizers = <NSArray: 0x178e13a0>; layer = <CALayer: 0x178dc930>>","tip":" "}
*/
FOUNDATION_EXPORT NSString * const CInfoEditorKey;
FOUNDATION_EXPORT NSString * const CInfoEditorLMarginKey;
FOUNDATION_EXPORT NSString * const CInfoEditorFocusKey;
FOUNDATION_EXPORT NSString * const CInfoEditorKeyboardTypeKey;
FOUNDATION_EXPORT NSString * const CInfoEditorSecureTextEntryKey;
FOUNDATION_EXPORT NSString * const CInfoEditorTextKey;
FOUNDATION_EXPORT NSString * const CInfoEditorTipKey;
This diff is collapsed.
//
// IBTTableViewInfo.h
// IBTTableViewKit
//
// Created by Xummer on 15/1/5.
// Copyright (c) 2015年 Xummer. All rights reserved.
//
#import "IBTTableViewUserInfo.h"
#import "IBTTableViewSectionInfo.h"
#import "IBTTableViewCellInfo.h"
#import "IBTTableView.h"
@class IBTTableView;
@protocol IBTTableViewInfoDelegate;
@interface IBTTableViewInfo : IBTTableViewUserInfo
@property(assign, nonatomic, setter=setDelegate:) id<IBTTableViewInfoDelegate> delegate;
- (id)initWithFrame:(CGRect)frame style:(UITableViewStyle)style;
- (IBTTableView *)getTableView;
// Section
// return |IBTTableViewSectionInfo|
- (IBTTableViewSectionInfo *)getSectionAt:(NSUInteger)secIndex;
- (void)addSection:(IBTTableViewSectionInfo *)section;
- (void)removeSectionAt:(NSUInteger)secIndex;
- (NSUInteger)getSectionCount;
- (void)clearAllSection;
// Cell
// return |IBTTableViewCellInfo|
- (IBTTableViewCellInfo *)getCellAtSection:(NSUInteger)section row:(NSUInteger)row;
- (void)removeCellAt:(NSIndexPath *)indexPath;
@end
This diff is collapsed.
//
// IBTTableViewInfoDelegate.h
// IBTTableViewKit
//
// Created by Xummer on 15/1/5.
// Copyright (c) 2015年 Xummer. All rights reserved.
//
#import <Foundation/Foundation.h>
@protocol IBTTableViewInfoDelegate <NSObject, UIScrollViewDelegate>
@optional
- (void)commitEditingForRowAtIndexPath:(NSIndexPath *)indexPath Cell:(id)cellInfo;
- (void)accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath Cell:(id)cellInfo;
@end
//
// IBTTableViewSectionInfo.h
// IBTTableViewKit
//
// Created by Xummer on 15/1/5.
// Copyright (c) 2015年 Xummer. All rights reserved.
//
#import "IBTTableViewUserInfo.h"
@class IBTTableViewCellInfo;
@interface IBTTableViewSectionInfo : IBTTableViewUserInfo
@property (assign, nonatomic) BOOL bUseDynamicSize;
@property (assign, nonatomic) CGFloat fFooterHeight;
@property (assign, nonatomic) CGFloat fHeaderHeight;
@property (weak, nonatomic) id makeFooterTarget;
@property (assign, nonatomic) SEL makeFooterSel;
@property (weak, nonatomic) id makeHeaderTarget;
@property (assign, nonatomic) SEL makeHeaderSel;
+ (IBTTableViewSectionInfo *)sectionInfoDefaut;
+ (IBTTableViewSectionInfo *)sectionInfoHeader:(NSString *)header;
+ (IBTTableViewSectionInfo *)sectionInfoFooter:(NSString *)footer;
+ (IBTTableViewSectionInfo *)sectionInfoHeader:(NSString *)header Footer:(NSString *)footer;
+ (IBTTableViewSectionInfo *)sectionInfoHeaderMakeSel:(SEL)sel makeTarget:(id)target;
+ (IBTTableViewSectionInfo *)sectionInfoHeaderWithView:(UIView *)view;
+ (IBTTableViewSectionInfo *)sectionInfoFooterWithView:(UIView *)view;
- (NSUInteger)getCellCount;
// return |IBTTableViewCellInfo|
- (IBTTableViewCellInfo *)getCellAt:(NSUInteger)index;
// cell |IBTTableViewCellInfo|
- (void)addCell:(IBTTableViewCellInfo *)cell;
- (void)removeCellAt:(NSUInteger)index;
- (void)setHeaderTitle:(NSString *)title;
- (void)setFooterTitle:(NSString *)title;
- (UIView *)getHeaderView;
- (void)setHeaderView:(UIView *)view;
- (void)setFooterView:(UIView *)view;
@end
#define IBT_GROUP_SECTION_HEADER_HEIGHT (26.0f)
#define IBT_SECTION_HEADER_DEFAULT_COLOR [UIColor colorWithRed:122/255.0f green:122/255.0f blue:123/255.0f alpha:1]
#define IBT_SECTION_HEADER_TOP_MARGIN (0.0f)
#define IBT_SECTION_HEADER_DEFAULT_FONT_SIZE (16.0f)
#define IBT_SECTION_HEADER_BOTTOM_MARGIN (6.0f)
#define IBT_SECTION_FOOTER_DEFAULT_COLOR IBT_SECTION_HEADER_DEFAULT_COLOR
#define IBT_SECTION_FOOTER_TOP_MARGIN (6.0f)
#define IBT_SECTION_FOOTER_DEFAULT_FONT_SIZE (14.0f)
#define IBT_SECTION_FOOTER_BOTTOM_MARGIN (9.0f)
FOUNDATION_EXPORT NSString * const SInfoHeaderKey;
FOUNDATION_EXPORT NSString * const SInfoFooterKey;
FOUNDATION_EXPORT NSString * const SInfoHeaderTitleKey;
FOUNDATION_EXPORT NSString * const SInfoFooterTitleKey;
//
// IBTTableViewSectionInfo.m
// IBTTableViewKit
//
// Created by Xummer on 15/1/5.
// Copyright (c) 2015年 Xummer. All rights reserved.
//
#import "IBTTableViewSectionInfo.h"
NSString * const SInfoHeaderKey = @"header";
NSString * const SInfoFooterKey = @"footer";
NSString * const SInfoHeaderTitleKey = @"headerTitle";
NSString * const SInfoFooterTitleKey = @"footerTitle";
#import "IBTTableViewCellInfo.h"
@interface IBTTableViewSectionInfo ()
{
NSMutableArray *_arrCells;
}
@end
@implementation IBTTableViewSectionInfo
#pragma mark - Life Cycle
- (instancetype)init
{
self = [super init];
if (self) {
}
return self;
}
- (void)dealloc {
_arrCells = nil;
}
#pragma mark - Class Method
+ (id)sectionInfoDefaut {
return [[IBTTableViewSectionInfo alloc] init];
}
+ (id)sectionInfoHeader:(NSString *)header {
IBTTableViewSectionInfo *sInfo = [[self class] sectionInfoDefaut];
[sInfo setHeaderTitle:header];
return sInfo;
}
+ (id)sectionInfoFooter:(NSString *)footer {
IBTTableViewSectionInfo *sInfo = [[self class] sectionInfoDefaut];
[sInfo setFooterTitle:footer];
return sInfo;
}
+ (id)sectionInfoHeader:(NSString *)header Footer:(NSString *)footer {
IBTTableViewSectionInfo *sInfo = [[self class] sectionInfoDefaut];
[sInfo setHeaderTitle:header];
[sInfo setFooterTitle:footer];
return sInfo;
}
+ (id)sectionInfoHeaderMakeSel:(SEL)sel makeTarget:(id)target {
IBTTableViewSectionInfo *sInfo = [[self class] sectionInfoDefaut];
sInfo.makeHeaderTarget = target;
sInfo.makeHeaderSel = sel;
return sInfo;
}
+ (id)sectionInfoHeaderWithView:(UIView *)view {
IBTTableViewSectionInfo *sInfo = [[self class] sectionInfoDefaut];
[sInfo setHeaderView:view];
return sInfo;
}
+ (id)sectionInfoFooterWithView:(UIView *)view {
IBTTableViewSectionInfo *sInfo = [[self class] sectionInfoDefaut];
[sInfo setFooterView:view];
return sInfo;
}
#pragma mark - Public Method
- (NSUInteger)getCellCount {
return [_arrCells count];
}
- (IBTTableViewCellInfo *)getCellAt:(NSUInteger)index {
if (index < [self getCellCount]) {
return _arrCells[ index ];
}
return nil;
}
- (void)addCell:(IBTTableViewCellInfo *)cell {
if (![cell isKindOfClass:[IBTTableViewCellInfo class]]) {
return;
}
if (!_arrCells) {
_arrCells = [NSMutableArray array];
}
[_arrCells addObject:cell];
}
- (void)removeCellAt:(NSUInteger)index {
if (index < [self getCellCount]) {
[_arrCells removeObjectAtIndex:index];
}
}
- (void)setHeaderTitle:(NSString *)title {
if (title) {
[self addUserInfoValue:title forKey:SInfoHeaderTitleKey];
self.fHeaderHeight = -1;
}
}
- (void)setFooterTitle:(NSString *)title {
if (title) {
[self addUserInfoValue:title forKey:SInfoFooterTitleKey];
self.fFooterHeight = -1;
}
}
- (UIView *)getHeaderView {
return [self getUserInfoValueForKey:SInfoHeaderKey];
}
- (void)setHeaderView:(UIView *)view {
if (view) {
[self addUserInfoValue:view forKey:SInfoHeaderKey];
self.fHeaderHeight = CGRectGetHeight(view.frame);
}
}
- (void)setFooterView:(UIView *)view {
if (view) {
[self addUserInfoValue:view forKey:SInfoFooterKey];
self.fFooterHeight = CGRectGetHeight(view.frame);
}
}
@end
//
// IBTTableViewUserInfo.h
// IBTTableViewKit
//
// Created by Xummer on 15/1/5.
// Copyright (c) 2015年 Xummer. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface IBTTableViewUserInfo : NSObject
@property (strong, nonatomic) id userInfo;
- (id)getUserInfoValueForKey:(id <NSCopying>)key;
- (void)addUserInfoValue:(id)value forKey:(id <NSCopying>)key;
@end
//
// IBTTableViewUserInfo.m
// IBTTableViewKit
//
// Created by Xummer on 15/1/5.
// Copyright (c) 2015年 Xummer. All rights reserved.
//
#import "IBTTableViewUserInfo.h"
@interface IBTTableViewUserInfo () {
NSMutableDictionary *_dicInfo;
}
@end
@implementation IBTTableViewUserInfo
- (id)getUserInfoValueForKey:(id <NSCopying>)key {
NSParameterAssert(key);
if (key && _dicInfo) {
return _dicInfo[ key ];
}
return nil;
}
- (void)addUserInfoValue:(id)value forKey:(id <NSCopying>)key {
NSParameterAssert(key);
if (value && key) {
if (!_dicInfo) {
_dicInfo = [NSMutableDictionary dictionary];
}
[_dicInfo setObject:value forKey:key];
}
else if (key) {
if (_dicInfo) {
[_dicInfo removeObjectForKey:key];
}
}
}
@end
//
// IBTBadgeView.h
// IBTTableViewKit
//
// Created by Xummer on 15/1/8.
// Copyright (c) 2015年 Xummer. All rights reserved.
//
#import <UIKit/UIKit.h>
#define DEFUALT_BADGE_HEIGHT (30.0f)
@class IBTUILabel;
@interface IBTBadgeView : UIImageView
@property (assign, nonatomic) BOOL bRightAlignment;
@property (assign, nonatomic) CGFloat fAddedWidth;
@property (assign, nonatomic) CGPoint pOriginPoint;
- (instancetype)initWithFrame:(CGRect)frame range:(CGFloat)range;
- (IBTUILabel *)labelView;
- (void)setUpView;
- (void)setBadgeColor:(UIColor *)color;
- (void)SetImage:(UIImage *)image;
- (void)setString:(NSString *)string;
- (void)setValue:(NSUInteger)value;
@end
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
//
// IBTObject.h
// IBTImagePicker
//
// Created by Xummer on 1/18/15.
// Copyright (c) 2015 Xummer. All rights reserved.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
@interface IBTObject : NSObject
@end
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment