Latest | 0.1 |
---|---|
Homepage | https://github.com/xt-input/XTInputKit |
License | MIT |
Platforms | ios 9.0, requires ARC |
Authors |
XTInputKit是一套swift版的代码集,暂时有:
XTILoger
来自:Loggerithm 感谢honghaoz
打印日志工具,在debug模式下会在终端窗口打印,release模式下返回构造的好的日志,
可以将其保存在指定的文件上传到自己的服务器做数据分析2018/3/21:添加保存日志到文件功能
示例:
var log = XTILoger.default //如果需要修改默认的日志等级不要直接使用XTLoger.default
log.debugLogLevel = .debug //debug模式的日志等级
log.releaseLogLevel = .warning //release模式的日志等级,在release模式下只会构造日志不会打印在控制台,可以自己保存到本地
log.info(format: "%@%@", args: self, self)
log.debug(format: "%@%@", args: self, self)
log.warning(format: "%@%@", args: self, self)
log.error(format: "%@%@", args: self, self)
XTILoger.default.info(1231)
XTILoger.default.debug(1231)
XTILoger.default.warning(1231)
XTILoger.default.error(1231)
后续会加入写入本地文件的功能
XTIMacros
整合一些常用的值,例如:
取屏幕宽度:XTMacros.SCREEN_WIDTH
取屏幕高度:XTMacros.SCREEN_HEIGHT
判断是否是iPhone x:XTMacros.isIphoneX
···等等的
XTITool
获取rootVC、currentVC、keyWindow
2018/3/21:添加通过版本号字符串比较版本号的函数
XTITool.keyWindow.rootViewController = ViewController() //修改根控制器
XTITool.currentVC.xti_pushOrPresentVC(ViewController()) //从当前活动的控制器调转到ViewController,如果当前控制器在navigetionVC上那么久push,否则present
UINavigationController
这部分的扩展来自:FDFullscreenPopGesture 感谢forkingdog
加入全屏滑动返回
有两个开关,一个是全局设置开关,需要在应用第一个UINavigationController对象初始化之前设置。
另一个是针对单个UINavigationController的,该开关优先级大于全局开关
使用方法:
在application(_:didFinishLaunchingWithOptions:)函数里:
UINavigationController.xti_openBackGesture = false
在项目UINavigationController封装的基类里:
override func xti_openBackGesture() -> Bool {
return ture
}
UIViewController
隐藏导航栏和禁用右划返回参考FDFullscreenPopGesture
禁用右划返回仅仅在
xti_openBackGesture
开启的时候才会生效扩展功能:
设置导航栏左右两边按钮<仅支持添加一个>,如果不带
action
参数,点击的回调则是xti_toucheLeftBarButtonItem
或xti_toucheRightBarButtonItem
xtisetBarButtonItem(:title:img:titleColor:action:)
跳转到其它控制器,根据当前控制器的跳转模式(push、present)自动选择跳转模式,动画参数默认是true
xtipushOrPresentVC(:animated:)
关闭当前控制器,和跳转其它控制器方法对应,动画参数默认是true,
completion
参数默认为nilxtipopOrDismiss(:completion:)
通过StoryBoard初始化控制器,该方法如果不传
withIdentifier
默认使用控制器类名,也就是说如果在StoryBoard里面将控制器的StoryBoard ID设置成类名就只要StoryBoard文件名一个参数就可以了initwithstoryboard(_:withIdentifier:)
设置展示在下一级界面导航栏返回按钮的文案和颜色,系统默认是显示该控制器的标题,颜色是蓝色
xti_nextBackTitle、xti_nextBackColor
设置不同的tabbar标题和navigation标题
xti_tabbarTitle、xti_navigationTitle
设置导航栏背景色,不支持透明通道,每一个控制器都可以设定不一样的颜色
xti_navigationBarBackgroundColor
使用方法:
self.xti_navigationTitle = "navigation标题" //设置导航栏标题,当导航栏标题和标签栏标题的不一致时使用
self.xti_setBarButtonItem(.right, title: "测试")//通过`title`设置导航栏右边的按钮,也可以通过图片设置
self.xti_nextBackTitle = "返回" //设置下一级控制器的导航栏返回按钮的文案
self.xti_nextBackColor = UIColor.red //设置下一级控制器的导航栏返回按钮的颜色
self.xti_navigationBarHidden = true //隐藏导航栏
self.xti_disabledBackGesture = true //禁用右划返回手势
self.xti_tabbarTitle = "tabbar标题" //设置标签栏标题,当导航栏标题和标签栏标题的不一致时使用
//通过Storyboard名字初始化控制器,并使用xti_pushOrPresentVC跳转
self.xti_pushOrPresentVC(ViewController.initwithstoryboard("Storyboard"))
//关闭当前控制器
self.xti_popOrDismiss()
//设置导航栏背景颜色
self.xti_navigationBarBackgroundColor = UIColor.red
UITabBarController
扩展一个直接添加addChildViewController的方法
将选中图片、默认图片、标签的标题、控制器做参数传递
xtiaddChildViewController(:tabbarTitle:image:selectedImage)
最后
有些功能扩展没有写上来,代码里有部分注释,请参考注释。
还有一些其他开发笔记之类的可以到我的博客上查看:小唐朝的blog
Latest podspec
{ "name": "XTInputKit", "version": "0.1", "summary": "u4e00u4e9bu5e38u7528u7684iOSu5f00u53d1u4ee3u7801u53cau6269u5c55u96c6u5408uff0cu4f8bu5982u6253u5370u65e5u5fd7u7684u5de5u5177XTILogeruff0cu752816u8fdbu5236u53d6u989cu8272uff0ckeychainuff0cNetWorku00b7u00b7u00b7", "description": "u5e73u65f6u5f00u53d1u79efu7d2fu7684u4ee3u7801u6574u5408u8d77u6765u7684u3002u5305u62ecu4e14u4e0du9650u4e8eUINavigationControlleru3001UIViewControlleru3001UITabBarControlleru7684u6269u5c55uff0cu4ee5u53caStringu3001Dateu3001DispatchQueueu7684u6269u5c55u3002", "homepage": "https://github.com/xt-input/XTInputKit", "license": "MIT", "authors": { "xt-input": "[email protected]" }, "platforms": { "ios": "9.0" }, "source": { "git": "https://github.com/xt-input/XTInputKit.git", "tag": "0.1" }, "requires_arc": true, "subspecs": [ { "name": "XTILoger", "source_files": "Source/XTILoger/*.swift", "pod_target_xcconfig": { "SWIFT_VERSION": "4.2" } }, { "name": "Extension", "source_files": "Source/Extension/**/*.swift", "pod_target_xcconfig": { "SWIFT_VERSION": "4.2" } }, { "name": "XTITool", "source_files": "Source/Class/*.swift", "pod_target_xcconfig": { "SWIFT_VERSION": "4.2" } }, { "name": "XTINetWork", "source_files": "Source/Network/*.swift", "pod_target_xcconfig": { "SWIFT_VERSION": "4.2" }, "dependencies": { "XTInputKit/XTILoger": [], "XTInputKit/XTITool": [], "HandyJSON": [ "~> 4.2.1" ], "Alamofire": [ "~> 4.8.1" ] } } ] }
Thu, 24 Jan 2019 11:37:00 +0000