- 博客(20)
- 收藏
- 关注
原创 UITableView优化
UITableView优化 1.按需加载,只加载目标范围内的Cell 2.高度预先计算并缓存 3.Cell重用,正确使用identifier 4.异步绘制(sd的使用) 5.尽量使用所有的viewopaque,包括Cell自身,尽量少用或者不用透明图层 ...
2021-06-08 20:58:39
170
原创 runtime--UITextView添加默认文字
#import <UIKit/UIKit.h> @interface UITextView (ZWPlaceHolder) /** * UITextView+placeholder */ @property (nonatomic, copy) NSString *zw_placeHolder; /** * IQKeyboardManager等第三方框架会读取placeholder属性并创建UIToolbar展示 */ @property (nonatomic, copy) N.
2020-12-08 18:06:25
221
原创 runtime之method_exchangeImplementations交换两个方法
#import "UIViewController+Swizzling.h" #import <objc/runtime.h> @implementation UIViewController (Swizzling) +(void)load{ //虽然load只执行一次,但是为了保险起见,我们还是给加个dispatch_once吧,良好的编程习惯,从这里开始 static dispatch_once_t token; dispatch_once(&token,.
2020-12-08 18:04:35
984
原创 CocoaHTTPServer编译报错 libxml/parser.h not found 解决方案
使用 CocoaHTTPServer 的时候,报错 libxml/parser.h not found 解决办法:添加链接库 libxml2.dylib 在 header search paths 处 添加 ${SDK_DIR}/usr/include/libxml2
2020-08-06 10:44:25
383
转载 xcode ios调试
升级 iOS 12 之后,使用 Xcode 9 真机调试会提示错误: Could not locate device support files. This iPhone 6 Plus is running iOS 12.0 (16A366), which may not be supported by this version of Xcode. 这是因为 Xcode 9 默认没有自带 iOS 12 的调试包,下载调试包,然后重新打开 Xcode 就可以了。 iOS 真机调试包集合,包含 iOS 12,下
2020-08-04 13:45:57
317
原创 swift中延迟执行
// 1.perform(必须在主线程中执行) self.perform(#selector(delayExecution), with: nil, afterDelay: 3) // 取消 NSObject.cancelPreviousPerformRequests(withTarget: self) // 2.timer(必须在主线程中执行) Timer.scheduledTimer(timeInterval: 3, target: self, selector: #selector(delayExe
2020-07-03 16:19:28
5036
原创 Ambiguous use of ‘setImage(with:placeholder:options:progressBlock:completion
avatarImgView.kf.setImage(with: URL(string: avarUrlOk), placeholder: nil, options: nil, progressBlock: nil, completionHandler: nil) } 不报错写法01 avatarImgView.kf.setImage(with: URL(string: avarUrlOk), placeholder: UIImage(named: "mine_defualt_head"))
2020-07-03 15:46:24
775
原创 Swift-代理用Weak修饰报错问题
weak 属性修饰会报错。 ‘weak’ must not be applied to non-class-bound ‘YJReaderRecommendOneBookViewProtocal’; consider adding a protocol conformance that has a class bound weak与弱引用计数有关,只能修饰对象,不能修饰协议限制的any。 3个解决方案: protocol YJReaderRecommendOneBookViewProtocal: NSObj
2020-06-18 15:27:39
4624
原创 swift-给View添加不同的圆角
import Foundation extension UIView { /// BezierPath 圆角设置 func roundCorners(_ corners: UIRectCorner = .allCorners, radius: CGFloat) { let maskPath = UIBezierPath( roundedRect: bounds, byRoundingCorners: corners.
2020-06-17 09:56:51
1009
原创 swift-可移动进度条
import UIKit //140 height 4 圆角就是 2 #EEEEEE 大的背景 小的背景#6CA9FF class YJProgressView: UIView { private let indicaterView = UIView() private var wholePageNum = 0 private var indivaterIndex = 0 //进度条畅读 var progressViewH: CGFloat {
2020-06-17 09:55:11
614
原创 iOS开发便捷代码--UIView设置圆角
let maskPath = UIBezierPath.init(roundedRect: self.bounds, byRoundingCorners: UIRectCorner(rawValue: UIRectCorner.topLeft.rawValue | UIRectCorner.topRight.rawValue), cornerRadii: CGSize.init(width: 50 , height:50)) let maskLayer = CAShapeL
2020-06-07 15:46:34
178
原创 ios判断系统版本
if #available(iOS 10.0, *) { }else { } if #available(tvOS 1.0, *) { } if #available(watchOS 1.0, *) { } if #available(OSX 10.11, *) { }
2020-05-26 15:04:29
565
原创 iOS 获取图片的主题色(主色调)
-(UIColor *)mainColorOfImage:(UIImage *)image{ #if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_6_1 int bitmapInfo =kCGBitmapByteOrderDefault | kCGImageAlphaPremultipliedLast; #else int bitmapInfo =...
2020-04-09 19:14:55
1341
原创 iOS开发便捷路径--Xcode开发包文件存放路径
将下载好的iOS 包文件解压复制:/applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport 文件夹下。 (注:打开finder 使用快捷键 command + shift + G 将红色的部分粘贴到框内 enter) ...
2020-04-08 20:04:35
693
原创 LanchScreen启动白屏更换启动图无效问题
StoryBord加载LanchScreen空白问题 LanchScreen启动白屏问题黑屏问题 有效方案 尝试N中方式,只有从xcode10上拉入新图片 xcode11中 其他无效方案: 把资源文件放入根目录,会出现黑屏问题; 将图片命名更改,重新将storyboad载入也不行; 重启xcode,重启手机,clean等你不能让用户卸载重启吧,不可行 ...
2020-04-01 18:41:24
484
原创 GCD-定时器
#import <UIKit/UIKit.h> @interface ViewController : UIViewController @property (assign, nonatomic) NSInteger surplusSecond; @property (strong, nonatomic) IBOutlet UILabel *lblMessage; @property ...
2020-01-14 15:05:41
251
原创 pod install --verbose --no-repo-update
pod install --verbose --no-repo-update pod update --verbose --no-repo-update
2020-01-08 15:29:32
254
原创 Dispatch(01)
Dispatch 通过提交工作来调度由系统管理的队列,在多核硬件上执行分配给队列的任务. GCD在iOS开发中是多线程开发中用的最多的。但是却不是像pthread和NSThread去直接操作线程的,GCD是用一个叫队列的东西来包装了线程,所以我们在开发中只需要操作好队列就可以了。完全不用去管理线程的创建和销毁。这样就大大减少了开发中遇到莫名其妙的bug。 Grand Central Dispatc...
2018-10-28 18:17:01
880
原创 GCD创建更加准确的定时器
NSTimer创建的定时器不是很准确,我们可以用GCD来创建一个准确的定时器 GCD不受RunLoop的影响(比如:scrollView在拖动的时候,定时器照样执行) @interface ViewController () /** * 定时器(这里不用带*,因为dispatch_source_t就是个类,内部已经包含了*) */ @property(nonatomic, str...
2018-09-02 12:40:45
435
原创 iOS-成员变量和属性理解
iOS 5之后: @property声明的属性默认会生成一个_类型的成员变量,同时也会生成setter/getter方法。 iOS 5之前: 1.一个大括号里面定义了成员变量 2.@property声明 3.@implementation中使用@synthesize方法。 Demo iOS5 之前是这样的 @interface ViewController () { // 1...
2018-09-02 10:38:36
325
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅