IOS开发基础之微博项目第1天-OC版
纯代码创建的项目,具有参考价值
该资料来自2014年7月3号,虽然时间过去较长,但是oc和swift不同,oc语法迭代更新慢
具有一定的参考意义
涉及xib加载,纯代码创建页面,导航控制器,类分类,PCH,宏定义,封装,UITableView的使用,代理,源码在我的主页下,名称是 04-WeiBo-OneDay-OC_Version.zip
核心源码
//
// AppDelegate.m
// 01-WeiBo-CreateFramework
//
// Created by 鲁军 on 2021/4/18.
//
#import "AppDelegate.h"
#import "HMTabBarViewController.h"
@interface AppDelegate ()
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [[UIWindow alloc] init];
self.window.frame = [UIScreen mainScreen].bounds;
self.window.rootViewController = [[HMTabBarViewController alloc] init];
[self.window makeKeyAndVisible];
return YES;
}
@end
PCH文件
#define HMRandomColor [UIColor colorWithRed:arc4random_uniform(256)/255.0 green:arc4random_uniform(256)/255.0 blue:arc4random_uniform(256)/255.0 alpha:1.0]
#define IOS7 ([[UIDevice currentDevice].systemVersion doubleValue] >= 7.0)
#import "UIView+Extension.h"
#import "UIBarButtonItem+Extension.h"
#ifdef DEBUG //调试状态。打开LOG功能
#define HMLog(...) NSLog(__VA_ARGS__)
#else//发布状态关闭LOG功能
#define HMLog(...)
#endif
//
// HMNavigationController.m
// 01-WeiBo-CreateFramework
//
// Created by 鲁军 on 2021/4/18.
#import "HMNavigationController.h"
@interface HMNavigationController ()
@end
@implementation HMNavigationController
- (void)viewDidLoad {
[super viewDidLoad];
}
+(void)initialize{
UIBarButtonItem *appearance = [UIBarButtonItem appearance];
NSMutableDictionary *textAttr = [NSMutableDictionary dictionary];
textAttr[NSForegroundColorAttributeName] = [UIColor orangeColor];
textAttr[NSFontAttributeName] =