内容声明
赤裸裸的使用本文内容去做所谓原创的, 麻烦要点脸.
Xcode11 缺失库文件导入位置变更
libstdc-6.0.9 文件下载
Xcode11 下 这个目录不存在了
/Applications/Xcode-beta.App/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/
[变更为]
/Applications/Xcode-beta.App/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/
---- 以下位置不需要改变
- /Applications/Xcode-beta.App/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib/
- /Applications/Xcode-beta.App/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib/
- /Applications/Xcode-beta.App/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/usr/lib/
友盟相关
升级最新版本 SDK
注册新浪平台 崩溃 [验证: 仅在模拟器上出现]
这个应该是需要微博官方进行适配了, 尝试模拟了 getUniqueStrByUUID 中的相关写法.
屏幕快照 2019-06-05 下午 1.47.08.PNG
暂时的解决方案:
- // 修复 iOS13 下 崩溃问题 验证为: 模拟器下出现
- #if TARGET_IPHONE_SIMULATOR
- /// 交换方法实现
- static dispatch_once_t onceToken;
- dispatch_once(&onceToken, ^{
- if(@available(iOS 13.0, *)){
- Method origin = class_getClassMethod([UIDevice class], NSSelectorFromString(@"getUniqueStrByUUID"));
- // IMP originImp = method_getImplementation(origin);
- Method swizz = class_getClassMethod([self class], @selector(swizz_getUniqueStrByUUID));
- // 交换方法实现
- method_exchangeImplementations(origin, swizz);
- }
- });
- #pragma mark - 获取唯一标识 新浪
- + (NSString *)swizz_getUniqueStrByUUID{
- CFUUIDRef uuidObj = CFUUIDCreate(nil);//create a new UUID
- //get the string representation of the UUID
- NSString *uuidString = (__bridge_transfer NSString *)CFUUIDCreateString(nil, uuidObj);
- CFRelease(uuidObj);
- return uuidString ;
- }
- #endif
+[_LSDefaults sharedInstance] 崩溃问题
针对的友盟版本:
移动统计: 6.0.5
消息推送: 3.2.4
社会化分享: 6.9.6
暂时的解决方案:
- @implementation NSObject (Extend)
- + (void)load{
- SEL originalSelector = @selector(doesNotRecognizeSelector:);
- SEL swizzledSelector = @selector(sw_doesNotRecognizeSelector:);
- Method originalMethod = class_getClassMethod(self, originalSelector);
- Method swizzledMethod = class_getClassMethod(self, swizzledSelector);
- if(class_addMethod(self, originalSelector, method_getImplementation(swizzledMethod), method_getTypeEncoding(swizzledMethod))){
- class_replaceMethod(self, swizzledSelector, method_getImplementation(originalMethod), method_getTypeEncoding(originalMethod));
- }else{
- method_exchangeImplementations(originalMethod, swizzledMethod);
- }
- }
- + (void)sw_doesNotRecognizeSelector:(SEL)aSelector{
- // 处理 _LSDefaults 崩溃问题
- if([[self description] isEqualToString:@"_LSDefaults"] && (aSelector == @selector(sharedInstance))){
- // 冷处理...
- return;
- }
- [self sw_doesNotRecognizeSelector:aSelector];
- }
DeviceToken 获取 友盟公告
- #include <arpa/.NET.h>
- - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
- {
- if (![deviceToken isKindOfClass:[NSData class]]) return;
- const unsigned *tokenBytes = (const unsigned *)[deviceToken bytes];
- NSString *hexToken = [NSString stringWithFormat:@"%08x%08x%08x%08x%08x%08x%08x%08x",
- ntohl(tokenBytes[0]), ntohl(tokenBytes[1]), ntohl(tokenBytes[2]),
- ntohl(tokenBytes[3]), ntohl(tokenBytes[4]), ntohl(tokenBytes[5]),
- ntohl(tokenBytes[6]), ntohl(tokenBytes[7])];
- NSLog(@"deviceToken:%@",hexToken);
- }
- UITextField
通过 KVC 方式修改空白提示语颜色 崩溃
[UITextField setValue:[UIColor redColor] forKeyPath:@"_placeholderLabel.textColor"];
解决方案:
attributedPlaceholder
leftView,rightView 设置异常 [疑似 iOS13beta4 新出现]
在设置 leftView 左按钮时, 如果使用的是 UIImageView 即会出现图片无法按照意图显示的问题.
@騲尼罵人獣狂 反馈 UITextField 的 rightView 的子视图如果使用约束布局, 会导致 rightView 覆盖整个 UITextField.
- // Confuse in beta4 iOS13
- UIImageView *imageIcon = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 34, 30)];
- //search_icon 15*15
- imageIcon.image = [UIImage imageNamed:@"search_icon"];
- imageIcon.contentMode = UIViewContentModeCenter;
- UITextField *txtSearch = [[UITextField alloc] init];
- txtSearch.leftView = imageIcon;
解决方案:
UIImageVIew 包一层 UIView 再设置给 leftView , 设置 leftView 或 rightView 不要使用约束布局
UISearchBar
- UISearchBar *searchBar = [[UISearchBar alloc]init];
- searchBar.searchTextField
- /*
- Defines the presentation style that will be used for this view controller when it is presented modally. Set this property on the view controller to be presented, not the presenter.
- If this property has been set to UIModalPresentationAutomatic, reading it will always return a concrete presentation style. By default UIViewController resolves UIModalPresentationAutomatic to UIModalPresentationPageSheet, but other system-provided view controllers may resolve UIModalPresentationAutomatic to other concrete presentation styles.
- Defaults to UIModalPresentationAutomatic on iOS starting in iOS 13.0, and UIModalPresentationFullScreen on previous versions. Defaults to UIModalPresentationFullScreen on all other platforms.
- */
- @property(nonatomic,assign) UIModalPresentationStyle modalPresentationStyle API_AVAILABLE(iOS(3.2));
- [nav setModalPresentationStyle:UIModalPresentationFullScreen];
- - (BOOL)shouldAutorotate {
- return NO;
- }
- - (UIInterfaceOrientationMask)supportedInterfaceOrientations {
- return UIInterfaceOrientationMaskLandscapeRight;
- }
- - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
- return UIInterfaceOrientationLandscapeRight;
- }
- UIColor *dynamicColor = [UIColor colorWithDynamicProvider:^UIColor * _Nonnull(UITraitCollection * provider) {
- // 使用 provider 判断, 有时会出问题
- if(keyWindow.isDark){
- return darkColor;
- }
- return lightColor;
- }];
- #pragma mark - DarkMode Adapater
- #ifdef __IPHONE_13_0
- - (void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection{
- [super traitCollectionDidChange:previousTraitCollection];
- if (@available(iOS 13.0, *)) {
- if([UITraitCollection.currentTraitCollection hasDifferentColorAppearanceComparedToTraitCollection:previousTraitCollection]){
- [self.layer setNeedsDisplay];
- }
- } else {
- // Fallback on earlier versions
- }
- }
- #endif
- #pragma mark - Dark mode Adapter
- #ifdef __IPHONE_13_0
- - (void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection{
- [super traitCollectionDidChange:previousTraitCollection];
- if (@available(iOS 13.0, *)) {
- if([UITraitCollection.currentTraitCollection hasDifferentColorAppearanceComparedToTraitCollection:previousTraitCollection]){
- [self _commitUpdate];
- }
- } else {
- // Fallback on earlier versions
- }
- }
- #endif
- - (void)setColor:(UIColor *)color {
- [self setColor:color range:NSMakeRange(0, self.length)];
- }
- - (void)setStrokeColor:(UIColor *)strokeColor {
- [self setStrokeColor:strokeColor range:NSMakeRange(0, self.length)];
- }
- - (void)setStrikethroughColor:(UIColor *)strikethroughColor {
- [self setStrikethroughColor:strikethroughColor range:NSMakeRange(0, self.length)];
- }
- - (void)setUnderlineColor:(UIColor *)underlineColor {
- [self setUnderlineColor:underlineColor range:NSMakeRange(0, self.length)];
- }
- UIImageView
- #pragma mark - 解决 Image 拉伸问题
- + (UITraitCollection *)lightTrait API_AVAILABLE(iOS(13.0)) {
- static UITraitCollection *trait = nil;
- static dispatch_once_t onceToken;
- dispatch_once(&onceToken, ^{
- trait = [UITraitCollection traitCollectionWithTraitsFromCollections:@[
- [UITraitCollection traitCollectionWithDisplayScale:UIScreen.mainScreen.scale],
- [UITraitCollection traitCollectionWithUserInterfaceStyle:UIUserInterfaceStyleLight]
- ]];
- });
- return trait;
- }
- + (UITraitCollection *)darkTrait API_AVAILABLE(iOS(13.0)) {
- static UITraitCollection *trait = nil;
- static dispatch_once_t onceToken;
- dispatch_once(&onceToken, ^{
- trait = [UITraitCollection traitCollectionWithTraitsFromCollections:@[
- [UITraitCollection traitCollectionWithDisplayScale:UIScreen.mainScreen.scale],
- [UITraitCollection traitCollectionWithUserInterfaceStyle:UIUserInterfaceStyleDark]
- ]];
- });
- return trait;
- }
- + (void)fixResizableImage API_AVAILABLE(iOS(13.0)) {
- Class klass = UIImage.class;
- SEL selector = @selector(resizableImageWithCapInsets:resizingMode:);
- Method method = class_getInstanceMethod(klass, selector);
- if (method == NULL) {
- return;
- }
- IMP originalImp = class_getMethodImplementation(klass, selector);
- if (!originalImp) {
- return;
- }
- IMP dynamicColorCompatibleImp = imp_implementationWithBlock(^UIImage *(UIImage *_self, UIEdgeInsets insets, UIImageResizingMode resizingMode) {
- // 理论上可以判断 UIColor 是否是 UIDynamicCatalogColor.class, 如果不是, 直接返回原实现; 但没必要.
- UITraitCollection *lightTrait = [self lightTrait];
- UITraitCollection *darkTrait = [self darkTrait];
- UIImage *resizable = ((UIImage * (*)(UIImage *, SEL, UIEdgeInsets, UIImageResizingMode))
- originalImp)(_self, selector, insets, resizingMode);
- UIImage *resizableInLight = [_self.imageAsset imageWithTraitCollection:lightTrait];
- UIImage *resizableInDark = [_self.imageAsset imageWithTraitCollection:darkTrait];
- if (resizableInLight) {
- [resizable.imageAsset registerImage:((UIImage * (*)(UIImage *, SEL, UIEdgeInsets, UIImageResizingMode))
- originalImp)(resizableInLight, selector, insets, resizingMode)
- withTraitCollection:lightTrait];
- }
- if (resizableInDark) {
- [resizable.imageAsset registerImage:((UIImage * (*)(UIImage *, SEL, UIEdgeInsets, UIImageResizingMode))
- originalImp)(resizableInDark, selector, insets, resizingMode)
- withTraitCollection:darkTrait];
- }
- return resizable;
- });
- class_replaceMethod(klass, selector, dynamicColorCompatibleImp, method_getTypeEncoding(method));
- }
- /// 常见的绘制代码
- UIGraphicsBeginImageContextWithOptions(contentSize,YES,[[UIScreen mainScreen] scale]);
- /// CGContextRef ctx = UIGraphicsGetCurrentContext();
- /// [self.viewContent.layer renderInContext:ctx];
- [self.viewContent drawViewHierarchyInRect:CGRectMake(0, 0, contentSize.width, contentSize.height) afterScreenUpdates:YES];
- // 生成图片
- UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
- UIGraphicsEndImageContext();
- UIImage* shotImage = nil;
- UITableView *scrollView = self.tableBase;
- // 临时数据
- CGPoint fltOriginOffset = scrollView.contentOffset;
- CGRect rectOrigin = scrollView.frame;
- scrollView.contentOffset = CGPointZero;
- scrollView.frame = CGRectMake(0, 0, scrollView.contentSize.width, scrollView.contentSize.height);
- UIGraphicsBeginImageContextWithOptions(CGSizeMake(scrollView.contentSize.width, scrollView.contentSize.height), scrollView.opaque, 0.0);
- [scrollView.layer renderInContext:UIGraphicsGetCurrentContext()];
- shotImage = UIGraphicsGetImageFromCurrentImageContext();
- UIGraphicsEndImageContext();
- // 状态复原
- scrollView.contentOffset = fltOriginOffset;
- scrollView.frame = rectOrigin;
- -[UICollectionView scrollViewShouldScrollToTop:]
- -[UIScrollView _scrollToTopIfPossible:] ()
- -[UIScrollView _scrollToTopFromTouchAtScreenLocation:resultHandler:] ()
- -[UIWindow _scrollToTopViewsUnderScreenPointIfNecessary:resultHandler:]_block_invoke.796 ()
- -[UIWindow _handleScrollToTopAtXPosition:resultHandler:] ()
- // 此处能看到有个新鲜的 UIStatusBarManager 是 iOS13 新增的类, 可以看到状态栏的点击事件已经被其接管了.
- // 经过实践, 出问题的时候该方法也能被正常调用故此排上以上调用栈方法.
- -[UIStatusBarManager _handleScrollToTopAtXPosition:] ()
- -[UIStatusBarManager handleTapAction:] ()
- static dispatch_once_t onceToken;
- dispatch_once(&onceToken, ^{
- if (![UIApplication isAppExtension]) {
- one = [self new];
- one.frame = (CGRect){.size = kScreenSize};
- one.userInteractionEnabled = NO;
- // 此处能看到 窗口等级是高于状态栏的, 但多次尝试等级调整均无果.
- one.windowLevel = UIWindowLevelStatusBar + 1;
- // 元凶在这里
- // 所以, 即使关闭了用户交互 但是它竟能够阻挡状态栏的事件, 但却对常规 Windows 的事件无任何影响...
- if (@available(iOS 13.0, *)) {
- // 费解的结果...
- one.hidden = YES;
- }else{
- one.hidden = NO;
- }
- // for iOS 9:
- one.opaque = NO;
- one.backgroundColor = [UIColor clearColor];
- one.layer.backgroundColor = [UIColor clearColor].CGColor;
- }
- });
- return one;
- #ifdef __IPHONE_13_0
- if (@available(iOS 13.0, *)) {
- self.automaticallyAdjustsScrollIndicatorInsets = NO;
- }
- #endif
- #pragma mark - 修复 iOS13 下滚动异常 API
- #ifdef __IPHONE_13_0
- - (void)scrollToItemAtIndexPath:(NSIndexPath *)indexPath atScrollPosition:(UICollectionViewScrollPosition)scrollPosition animated:(BOOL)animated{
- [super scrollToItemAtIndexPath:indexPath atScrollPosition:scrollPosition animated:animated];
- // 修复 13 下 Cell 滚动位置异常
- if (@available(iOS 13.0, *)) {
- // 顶部
- if(self.contentOffset.y <0){
- [self setContentOffset:CGPointZero];
- return;
- }
- // 底部
- if(self.contentOffset.y> self.contentSize.height){
- [self setContentOffset:CGPointMake(0, self.contentSize.height)];
- }
- }
- }
- #endif
- [self addSubView: viewObjA]
- [self.contentView addSubview:viewObjB]
- [viewMain addSubView:viewA];
- [viewMain addSubView:viewB];
- // 更新 viewA 的约束
- [self.imageBackground mas_updateConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(50);
- }];
- // 立即更新约束
- [viewA.superview setNeedsUpdateConstraints];
- [viewA.superview updateConstraintsIfNeeded];
- [viewA.superview layoutIfNeeded];
- // 更新容器约束
- [viewMain mas_updateConstraints:^(MASConstraintMaker *make) {
- make....
- }];
- ....
- ....
- // 更新 viewA 的约束 [代码不会生效]
- [self.imageBackground mas_updateConstraints:^(MASConstraintMaker *make) {
- make.top.mas_equalTo(100);
- }];
- WKWebView
- gesture.cancelsTouchesInView = YES;
- gesture.delaysTouchesBegan = YES;
- ///UITextView override
- #ifdef __IPHONE_13_0
- // 用于解决 iOS13 下, 可拖动 UITextView 场景中放大镜手势引起的异常激活编辑状态问题.
- -(void)addInteraction:(id<UIInteraction>)interaction{
- [super addInteraction:interaction];
- if(!self.otherGestureRecognizer || self.otherGestureRecognizer.count == 0){
- return;
- }
- if([interaction isKindOfClass:NSClassFromString(@"UITextLoupeInteraction")]){
- UIGestureRecognizer *delayLoupeGesture = [self.gestureRecognizers objectWithBlock:^BOOL(UIGestureRecognizer *obj) {
- return [obj isKindOfClass:NSClassFromString(@"UIVariableDelayLoupeGesture")];
- }];
- if(delayLoupeGesture){
- [self.otherGestureRecognizer forEach:^(UIGestureRecognizer *obj) {
- [delayLoupeGesture requireGestureRecognizerToFail:obj];
- }];
- }
- }
- }
- #endif
- _updateSelectionView {
- ...
- ...
- }
- if (notify) [_inputDelegate selectionWillChange:self];
- if (notify) [_inputDelegate selectionDidChange:self];
- /// YYTextView.m
- /// 增加标记位
- struct {
- .....
- unsigned int trackingDeleteBackward : 1; ///<track deleteBackward operation
- unsigned int trackingTouchBegan : 1; /// < track touchesBegan event
- } _state;
- /// 方法重写
- #pragma mark - override
- - (void)addSubview:(UIView *)view{
- // 解决蓝点问题
- Class Cls_selectionGrabberDot = NSClassFromString(@"UISelectionGrabberDot");
- if ([view isKindOfClass:[Cls_selectionGrabberDot class]]) {
- view.backgroundColor = [UIColor clearColor];
- view.tintColor = [UIColor clearColor];
- view.size = CGSizeZero;
- }
- // 获取 UITextSelectionView
- // 解决双光标问题
- Class Cls_selectionView = NSClassFromString(@"UITextSelectionView");
- if ([view isKindOfClass:[Cls_selectionView class]]) {
- view.backgroundColor = [UIColor clearColor];
- view.tintColor = [UIColor clearColor];
- view.hidden = YES;
- }
- [super addSubview:view];
- }
- /// 方法修改
- /// Replace the range with the text, and change the `_selectTextRange`.
- /// The caller should make sure the `range` and `text` are valid before call this method.
- - (void)_replaceRange:(YYTextRange *)range withText:(NSString *)text notifyToDelegate:(BOOL)notify{
- if (_isExcludeNeed) {
- notify = NO;
- }
- if (NSEqualRanges(range.asRange, _selectedTextRange.asRange)) {
- // 这里的代理方法需要注释掉 [废止]
- //if (notify) [_inputDelegate selectionWillChange:self];
- /// iOS13 下, 双光标问题 便是由此而生.
- if (_state.trackingDeleteBackward)[_inputDelegate selectionWillChange:self];
- NSRange newRange = NSMakeRange(0, 0);
- newRange.location = _selectedTextRange.start.offset + text.length;
- _selectedTextRange = [YYTextRange rangeWithRange:newRange];
- //if (notify) [_inputDelegate selectionDidChange:self];
- /// iOS13 下, 双光标问题 便是由此而生.
- if (_state.trackingDeleteBackward) [_inputDelegate selectionDidChange:self];
- /// 恢复标记
- _state.trackingDeleteBackward = NO;
- } else {
- .....
- .....
- }
- - (void)deleteBackward {
- // 标识出删除动作: 用于解决双光标相关问题
- _state.trackingDeleteBackward = YES;
- [self _updateIfNeeded];
- .....
- .....
- }
- - (void)_updateSelectionView {
- _selectionView.frame = _containerView.frame;
- _selectionView.caretBlinks = NO;
- _selectionView.caretVisible = NO;
- _selectionView.selectionRects = nil;
- .....
- .....
- if (@available(iOS 13.0, *)) {
- if (_state.trackingTouchBegan) [_inputDelegate selectionWillChange:self];
- [[YYTextEffectWindow sharedWindow] showSelectionDot:_selectionView];
- if (_state.trackingTouchBegan) [_inputDelegate selectionDidChange:self];
- }else{
- [[YYTextEffectWindow sharedWindow] showSelectionDot:_selectionView];
- }
- if (containsDot) {
- [self _startSelectionDotFixTimer];
- } else {
- [self _endSelectionDotFixTimer];
- .....
- .....
- }
- #ifdef __IPHONE_13_0
- - (UIEditingInteractionConfiguration)editingInteractionConfiguration{
- return UIEditingInteractionConfigurationNone;
- }
- #endif
- UITabbar
- if #available(iOS 13, *) {
- let appearance = self.tabBar.standardAppearance.copy()
- appearance.backgroundImage = UIImage()
- appearance.shadowImage = UIImage()
- appearance.shadowColor = .clear
- self.tabBar.standardAppearance = appearance
- } else {
- self.tabBar.shadowImage = UIImage()
- self.tabBar.backgroundImage = UIImage()
- }
- // 容错性更高
- // 具体待补充
- #pragma mark - 旋转屏幕
- +(void)changeOrientation:(UIInterfaceOrientation)toOrientation{
- if ([[UIDevice currentDevice] respondsToSelector:@selector(setOrientation:)]) {
- SEL selector = NSSelectorFromString(@"setOrientation:");
- NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[UIDeviceinstanceMethodSignatureForSelector:selector]];
- [invocation setSelector:selector];
- [invocation setTarget:[UIDevice currentDevice]];
- int val = UIInterfaceOrientationLandscapeRight;
- [invocation setArgument:&val atIndex:2];
- [invocation invoke];
- }
- }
- #pragma mark - 旋转屏幕
- +(void)changeOrientation:(UIInterfaceOrientation)toOrientation{
- [self uploadLog:@"旋转屏幕"];
- if ([[UIDevice currentDevice] respondsToSelector:@selector(setOrientation:)]) {
- SEL selector = NSSelectorFromString(@"setOrientation:");
- NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[UIDeviceinstanceMethodSignatureForSelector:selector]];
- [invocation setSelector:selector];
- [invocation setTarget:[UIDevice currentDevice]];
- int val = UIInterfaceOrientationLandscapeRight;
- [invocation setArgument:&val atIndex:2];
- [invocation invoke];
- }
- }
- if (@available(iOS 13.0, *)) {
- UIView *_localStatusBar = [[UIApplication sharedApplication].keyWindow.windowScene.statusBarManager performSelector:@selector(createLocalStatusBar)];
- UIView * statusBar = [_localStatusBar performSelector:@selector(statusBar)];
- // 注意此代码不生效 用于绘制
- // [statusBar drawViewHierarchyInRect:statusBar.bounds afterScreenUpdates:NO];
- [statusBar.layer renderInContext:context];
- } else {
- // Fallback on earlier versions
- }
- UIWindow *keyWindow = [UIApplication sharedApplication].keyWindow;
- UIView *viewStatusColorBlend = [[UIView alloc]initWithFrame:keyWindow.windowScene.statusBarManager.statusBarFrame];
- viewStatusColorBlend.backgroundColor = Color;
- [keyWindow addSubview:viewStatusColorBlend];
- /** 状态栏 --iOS13 */
- @property (nonatomic, strong) UIView *viewStatusBar API_AVAILABLE(iOS(13.0));
- - (UIView *)viewStatusBar{
- if (!_viewStatusBar) {
- #pragma clang diagnostic push
- #pragma clang diagnostic ignored "-Wundeclared-selector"
- _viewStatusBar = [[UIApplication sharedApplication].keyWindow.windowScene.statusBarManager performSelector:@selector(createLocalStatusBar)];
- _viewStatusBar.backgroundColor = [UIColor clearColor];
- _viewStatusBar.hidden = YES;
- _viewStatusBar.tag = 784321;
- _viewStatusBar.overrideUserInterfaceStyle = UIUserInterfaceStyleLight;
- // 手动设置状态栏为白色样式
- UIView *statusBar = [[_viewStatusBar valueForKey:@"_statusBar"]valueForKey:@"_statusBar"];
- [statusBar performSelector:@selector(setForegroundColor:) withObject:[UIColor whiteColor]];
- #pragma clang diagnostic pop
- }
- return _viewStatusBar;
- }
- #param mark - 横屏方法
- - (void)setOrientationLandscapeConstraint {
- // 状态栏处理
- if (@available(iOS 13.0, *)) {
- if(![self viewWithTag:784321] && !DP_IS_IPAD){
- self.viewStatusBar.hidden = NO;
- [self addSubview:self.viewStatusBar];
- // 我这里是为了避开 其它控件, 具体的按各自的需求来
- CGFloat fltLeftMargin = DP_IS_IPHONEX ? (-24) : 0;
- CGFloat fltTopMargin = DP_IS_IPHONEX ? (-12) : 0;
- UIView *leftView = DP_IS_IPHONEX ? self.lblTitle : self;
- [self.viewStatusBar mas_makeConstraints:^(MASConstraintMaker *make) {
- make.left.mas_equalTo(leftView.mas_left).offset(fltLeftMargin);
- make.top.mas_equalTo(fltTopMargin);
- make.right.mas_equalTo(0);
- }];
- }
- }
- }
- #param mark - 竖屏方法
- - (void)setOrientationPortraitConstraint {
- // 状态栏处理
- if (@available(iOS 13.0, *)) {
- if (!DP_IS_IPAD) {
- self.viewStatusBar.hidden = YES;
- if ([self viewWithTag:784321]) {
- [self.viewStatusBar removeFromSuperview];
- }
- }
- }
- }
- @implementation UIStatusBarManager (Extend)
- /// 更改默认配置
- - (CGFloat)defaultStatusBarHeightInOrientation:(UIInterfaceOrientation)orientation {
- if (orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight ) {
- /// 主要就是这里
- return 20;
- }
- /// 此处仅做示例, 实际使用需要针对不同设备进行适配.
- return 44;
- }
- @end
- // 是否支持触摸力度检测
- if(self.Windows.traitCollection.forceTouchCapability == UIForceTouchCapabilityUnavailable){
- // 不支持触摸力度检测时, 检测是否支持 haptic touch.
- //haptic touch, 判断依据 仅 iOS 13.0 以上版本.
- if(@available(iOS 13.0, *)) {
- }else{
- return;
- }
- }
- UIStatusBarManager
- .cxx_destruct
- setWindowScene:
- _settingsDiffActionsForScene:
- initWithScene:
- _scene
- _setScene:
- windowScene
- isStatusBarHidden
- defaultStatusBarHeightInOrientation:
- statusBarStyle
- statusBarHeight
- updateStatusBarAppearance
- updateLocalStatusBars
- statusBarHidden
- statusBarAlpha
- setupForSingleLocalStatusBar
- statusBarFrameForStatusBarHeight:
- updateStatusBarAppearanceWithAnimationParameters:
- _updateStatusBarAppearanceWithClientSettings:transitionContext:animationParameters:
- _updateVisibilityForWindow:targetOrientation:animationParameters:
- _updateStyleForWindow:animationParameters:
- _updateAlpha
- _visibilityChangedWithOriginalOrientation:targetOrientation:animationParameters:
- activateLocalStatusBar:
- _updateLocalStatusBar:
- statusBarFrame
- _handleScrollToTopAtXPosition:
- _adjustedLocationForXPosition:
- updateStatusBarAppearanceWithClientSettings:transitionContext:
- deactivateLocalStatusBar:
- createLocalStatusBar
- handleTapAction:
- localStatusBars
- setLocalStatusBars:
- statusBarPartStyles
- isInStatusBarFadeAnimation
- debugMenuHandler
- setDebugMenuHandler:
- UIStatusBar_Modern
- .cxx_destruct
- layoutSubviews
- intrinsicContentSize
- setMode:
- setOrientation:
- currentStyle
- forceUpdate:
- statusBar
- setStatusBar:
- forceUpdateData:
- setEnabledPartIdentifiers:
- setAvoidanceFrame:
- frameForPartWithIdentifier:
- alphaForPartWithIdentifier:
- setAlpha:forPartWithIdentifier:
- setOffset:forPartWithIdentifier:
- jiggleLockIcon
- setForegroundColor:animationParameters:
- setStyleRequest:animationParameters:
- enabledPartIdentifiers
- setAction:forPartWithIdentifier:
- statusBarServer:didReceiveStatusBarData:withActions:
- statusBarServer:didReceiveStyleOverrides:
- statusBarServer:didReceiveDoubleHeightStatusString:forStyle:
- statusBarStateProvider:didPostStatusBarData:withActions:
- defaultDoubleHeight
- setForegroundAlpha:animationParameters:
- _effectiveStyleFromStyle:
- actionForPartWithIdentifier:
- offsetForPartWithIdentifier:
- _initWithFrame:showForegroundView:wantsServer:inProcessStateProvider:
- setLegibilityStyle:animationParameters:
- _requestStyle:partStyles:animationParameters:forced:
- _implicitStyleOverrideForStyle:
- _effectiveDataFromData:activeOverride:canUpdateBackgroundActivity:
- _updateWithData:force:
- _requestStyle:partStyles:legibilityStyle:foregroundColor:animationParameters:
- _updateSemanticContentAttributeFromLegacyData:
- _dataFromLegacyData:
- _UIStatusBarLocalView
- .cxx_destruct
- initWithFrame:
- willMoveToWindow:
- statusBar
- setStatusBar:
- _UIStatusBar
- description
- .cxx_destruct
- setAction:
- action
- layoutSubviews
- intrinsicContentSize
- mode
- initWithStyle:
- setMode:
- items
- style
- orientation
- setOrientation:
- foregroundColor
- containerView
- _updateDisplayedItemsWithData:styleAttrib
- updateConstraints
- setStyle:
- gestureRecognizerShouldBegin:
- currentData
- traitCollectionDidChange:
- setItems:
- setForegroundColor:
- areAnimationsEnabled
- setSemanticContentAttribute:
- updateWithData:
- setStyleAttributes:
- styleAttributes
- itemWithIdentifier:
- regions
- _traitCollectionForChildEnvironment:
- _accessibilityHUDGestureManager:HUDItemFo
- _accessibilityHUDGestureManager:gestureLi
- _accessibilityHUDGestureManager:shouldRec
- _accessibilityHUDGestureManager:shouldTer
- _accessibilityHUDGestureManager:showHUDIt
- _dismissAccessibilityHUDForGestureManager
- foregroundView
- actionGestureRecognizer
- avoidanceFrame
- setEnabledPartIdentifiers:
- setAvoidanceFrame:
- frameForPartWithIdentifier:
- alphaForPartWithIdentifier:
- setAlpha:forPartWithIdentifier:
- setOffset:forPartWithIdentifier:
- enabledPartIdentifiers
- setOverlayData:
- setAction:forPartWithIdentifier:
- setStyle:forPartWithIdentifier:
- overlayData
- updateCompletionHandler
- setUpdateCompletionHandler:
- setForegroundView:
- visualProvider
- _forceLayoutEngineSolutionInRationalEdges
- resizeSubviewsWithOldSize:
- currentAggregatedData
- updateWithAnimations:
- styleAttributesForStyle:
- displayItemIdentifiersInRegionsWithIdenti
- frameForDisplayItemWithIdentifier:
- frameForPartWithIdentifier:includeInterna
- dataAggregator
- displayItemWithIdentifier:
- regionWithIdentifier:
- stateForDisplayItemWithIdentifier:
- setDisplayItemStates:
- _updateWithAggregatedData:
- statusBarGesture:
- _setVisualProviderClass:
- _visualProviderClass
- _prepareVisualProviderIfNeeded
- _effectiveTargetScreen
- _updateStyleAttributes
- _performWithInheritedAnimation:
- _effectiveStyleFromStyle:
- _updateWithData:completionHandler:
- _prepareAnimations:
- _performAnimations:
- _fixupDisplayItemAttributes
- _delayUpdatesWithKeys:fromAnimation:
- _updateRegionItems
- _rearrangeOverflowedItems
- _frameForActionable:actionInsets:
- _gestureRecognizer:touchInsideActionable:
- _gestureRecognizer:pressInsideActionable:
- _frameForActionable:
- _pressFrameForActionable:
- _gestureRecognizer:isInsideActionable:
- _regionsForPartWithIdentifier:includeInte
- _actionablesForPartWithIdentifier:include
- _itemWithIdentifier:createIfNeeded:
- _statusBarWindowForAccessibilityHUD
- _setVisualProviderClassName:
- _visualProviderClassName
- resetVisualProvider
- actionForPartWithIdentifier:
- offsetForPartWithIdentifier:
- styleForPartWithIdentifier:
- dependentDataEntryKeys
- animationContextId
- itemsDependingOnKeys:
- itemIdentifiersInRegionsWithIdentifiers:
- dataEntryKeysForItemsWithIdentifiers:
- targetScreen
- setTargetScreen:
- displayItemStates
- targetActionable
- setTargetActionable:
- accessibilityHUDGestureManager
- setAccessibilityHUDGestureManager:
- (lldb) po [statusBar performSelector:@selector(currentData)]
- <_UIStatusBarData: 0x7fee29fdada0:
- mainBatteryEntry=<_UIStatusBarDataBatteryEntry: 0x600001713c90: isEnabled=1, capacity=100, state=2, saverModeActive=0, prominentlyShowsDetailString=0, detailString=100%>,
- secondaryCellularEntry=<_UIStatusBarDataCellularEntry: 0x600003c4d9e0: isEnabled=1, rawValue=0, displayValue=0, displayRawValue=0, status=0, lowDataModeActive=0, type=5, wifiCallingEnabled=0, callForwardingEnabled=0, showsSOSWhenDisabled=0>,
- backNavigationEntry=<_UIStatusBarDataStringEntry: 0x60000191e540: isEnabled=0>,
- vpnEntry=<_UIStatusBarDataEntry: 0x600001aae360: isEnabled=0>,
- radarEntry=<_UIStatusBarDataBoolEntry: 0x600001aae280: isEnabled=0, boolValue=0>,
- rotationLockEntry=<_UIStatusBarDataEntry: 0x600001aadf20: isEnabled=0>, dateEntry=<_UIStatusBarDataStringEntry: 0x60000191e560: isEnabled=1, stringValue=Thu Sep 26>,
- quietModeEntry=<_UIStatusBarDataBoolEntry: 0x600001aae250: isEnabled=0, boolValue=0>,
- timeEntry=<_UIStatusBarDataStringEntry: 0x60000191e580: isEnabled=1, stringValue=5:15 PM>,
- personNameEntry=<_UIStatusBarDataStringEntry: 0x60000191e5a0: isEnabled=0>,
- cellularEntry=<_UIStatusBarDataCellularEntry: 0x600003c4da40: isEnabled=1, rawValue=0, displayValue=0, displayRawValue=0, status=1, lowDataModeActive=0, type=5, string=Carrier, wifiCallingEnabled=0, callForwardingEnabled=0, showsSOSWhenDisabled=0>,
- assistantEntry=<_UIStatusBarDataEntry: 0x600001aae210: isEnabled=0>,
- bluetoothEntry=<_UIStatusBarDataBluetoothEntry: 0x60000191e5c0: isEnabled=0, state=0>,
- ttyEntry=<_UIStatusBarDataEntry: 0x600001aacbc0: isEnabled=0>,
- voiceControlEntry=<_UIStatusBarDataVoiceControlEntry: 0x60000191e5e0: isEnabled=0, type=0>,
- carPlayEntry=<_UIStatusBarDataEntry: 0x600001aacc00: isEnabled=0>,
- wifiEntry=<_UIStatusBarDataWifiEntry: 0x6000003b2880: isEnabled=1, rawValue=0, displayValue=3, displayRawValue=0, status=5, lowDataModeActive=0, type=0>,
- liquidDetectionEntry=<_UIStatusBarDataEntry: 0x600001aae160: isEnabled=0>,
- shortTimeEntry=<_UIStatusBarDataStringEntry: 0x60000191e600: isEnabled=1, stringValue=5:15>,
- studentEntry=<_UIStatusBarDataEntry: 0x600001aaeac0: isEnabled=0>,
- tetheringEntry=<_UIStatusBarDataTetheringEntry: 0x60000191e620: isEnabled=0, connectionCount=0>,
- alarmEntry=<_UIStatusBarDataEntry: 0x600001aae0e0: isEnabled=0>,
- activityEntry=<_UIStatusBarDataActivityEntry: 0x60000191e640: isEnabled=0, type=0, displayId=com.driver.feng>,
- locationEntry=<_UIStatusBarDataLocationEntry: 0x60000191e660: isEnabled=0, type=1>,
- airPlayEntry=<_UIStatusBarDataEntry: 0x600001aadfc0: isEnabled=0>,
- deviceNameEntry=<_UIStatusBarDataStringEntry: 0x60000191e680: isEnabled=0>,
- lockEntry=<_UIStatusBarDataLockEntry: 0x60000191e6a0: isEnabled=0, unlockFailureCount=0>,
- electronicTollCollectionEntry=<_UIStatusBarDataBoolEntry: 0x600001aae030: isEnabled=0, boolValue=0>,
- thermalEntry=<_UIStatusBarDataThermalEntry: 0x60000191e6c0: isEnabled=0, color=0, sunlightMode=0>,
- backgroundActivityEntry=<_UIStatusBarDataBackgroundActivityEntry: 0x600001713ed0: isEnabled=0, type=0>,
- forwardNavigationEntry=<_UIStatusBarDataStringEntry: 0x60000191e700: isEnabled=0>,
- airplaneModeEntry=<_UIStatusBarDataEntry: 0x600001aadfa0: isEnabled=0>>
- (lldb) po [statusBar performSelector:@selector(items)]
- {
- "<_UIStatusBarIdentifier: 0x600001907300: object=_UIStatusBarIndicatorTTYItem>" = "<_UIStatusBarIndicatorTTYItem: 0x6000003b1d40: identifier=<_UIStatusBarIdentifier: 0x600001907300: object=_UIStatusBarIndicatorTTYItem>>";
- "<_UIStatusBarIdentifier: 0x600001903a00: object=_UIStatusBarTimeItem>" = "<_UIStatusBarTimeItem: 0x600003b7f610: identifier=<_UIStatusBarIdentifier: 0x600001903a00: object=_UIStatusBarTimeItem>>";
- "<_UIStatusBarIdentifier: 0x600001907380: object=_UIStatusBarIndicatorAlarmItem>" = "<_UIStatusBarIndicatorAlarmItem: 0x6000003b1e00: identifier=<_UIStatusBarIdentifier: 0x600001907380: object=_UIStatusBarIndicatorAlarmItem>>";
- "<_UIStatusBarIdentifier: 0x600001906f80: object=_UIStatusBarSpacerItem>" = "<_UIStatusBarSpacerItem: 0x60000177ea00: identifier=<_UIStatusBarIdentifier: 0x600001906f80: object=_UIStatusBarSpacerItem>>";
- "<_UIStatusBarIdentifier: 0x600001903d60: object=_UIStatusBarActivityItem_Split>" = "<_UIStatusBarActivityItem_Split: 0x6000003b2000: identifier=<_UIStatusBarIdentifier: 0x600001903d60: object=_UIStatusBarActivityItem_Split>>";
- "<_UIStatusBarIdentifier: 0x600001903960: object=_UIStatusBarCellularCondensedItem>" = "<_UIStatusBarCellularCondensedItem: 0x600002aa8ea0: identifier=<_UIStatusBarIdentifier: 0x600001903960: object=_UIStatusBarCellularCondensedItem>>";
- "<_UIStatusBarIdentifier: 0x600001903a80: object=_UIStatusBarVoiceControlPillItem>" = "<_UIStatusBarVoiceControlPillItem: 0x600003b7f980: identifier=<_UIStatusBarIdentifier: 0x600001903a80: object=_UIStatusBarVoiceControlPillItem>>";
- "<_UIStatusBarIdentifier: 0x600001907400: object=_UIStatusBarIndicatorRotationLockItem>" = "<_UIStatusBarIndicatorRotationLockItem: 0x6000003b1e40: identifier=<_UIStatusBarIdentifier: 0x600001907400: object=_UIStatusBarIndicatorRotationLockItem>>";
- "<_UIStatusBarIdentifier: 0x600001907000: object=_UIStatusBarBluetoothItem>" = "<_UIStatusBarBluetoothItem: 0x6000003b1f00: identifier=<_UIStatusBarIdentifier: 0x600001907000: object=_UIStatusBarBluetoothItem>>";
- "<_UIStatusBarIdentifier: 0x600001906ee0: object=_UIStatusBarIndicatorAirplaneModeItem>" = "<_UIStatusBarIndicatorAirplaneModeItem: 0x6000003b2080: identifier=<_UIStatusBarIdentifier: 0x600001906ee0: object=_UIStatusBarIndicatorAirplaneModeItem>>";
- "<_UIStatusBarIdentifier: 0x600001907760: object=_UIStatusBarBuildVersionItem>" = "<_UIStatusBarBuildVersionItem: 0x60000177e310: identifier=<_UIStatusBarIdentifier: 0x600001907760: object=_UIStatusBarBuildVersionItem>>";
- "<_UIStatusBarIdentifier: 0x600001906d20: object=_UIStatusBarIndicatorVPNItem>" = "<_UIStatusBarIndicatorVPNItem: 0x6000003b1fc0: identifier=<_UIStatusBarIdentifier: 0x600001906d20: object=_UIStatusBarIndicatorVPNItem>>";
- "<_UIStatusBarIdentifier: 0x600001907480: object=_UIStatusBarIndicatorQuietModeItem>" = "<_UIStatusBarIndicatorQuietModeItem: 0x6000003b1e80: identifier=<_UIStatusBarIdentifier: 0x600001907480: object=_UIStatusBarIndicatorQuietModeItem>>";
- "<_UIStatusBarIdentifier: 0x6000019075a0: object=_UIStatusBarActivityItem_SyncOnly>" = "<_UIStatusBarActivityItem_SyncOnly: 0x60000177dad0: identifier=<_UIStatusBarIdentifier: 0x6000019075a0: object=_UIStatusBarActivityItem_SyncOnly>>";
- "<_UIStatusBarIdentifier: 0x6000019076c0: object=_UIStatusBarIndicatorLiquidDetectionItem>" = "<_UIStatusBarIndicatorLiquidDetectionItem: 0x6000003b1f40: identifier=<_UIStatusBarIdentifier: 0x6000019076c0: object=_UIStatusBarIndicatorLiquidDetectionItem>>";
- "<_UIStatusBarIdentifier: 0x600001907080: object=_UIStatusBarThermalItem>" = "<_UIStatusBarThermalItem: 0x6000003b1c80: identifier=<_UIStatusBarIdentifier: 0x600001907080: object=_UIStatusBarThermalItem>>";
- "<_UIStatusBarIdentifier: 0x600001906dc0: object=_UIStatusBarSecondaryCellularExpandedItem>" = "<_UIStatusBarSecondaryCellularExpandedItem: 0x60000366c380: identifier=<_UIStatusBarIdentifier: 0x600001906dc0: object=_UIStatusBarSecondaryCellularExpandedItem>>";
- "<_UIStatusBarIdentifier: 0x600001907500: object=_UIStatusBarIndicatorLocationItem>" = "<_UIStatusBarIndicatorLocationItem: 0x6000003b1ec0: identifier=<_UIStatusBarIdentifier: 0x600001907500: object=_UIStatusBarIndicatorLocationItem>>";
- "<_UIStatusBarIdentifier: 0x600001907100: object=_UIStatusBarIndicatorAssistantItem>" = "<_UIStatusBarIndicatorAssistantItem: 0x6000003b1cc0: identifier=<_UIStatusBarIdentifier: 0x600001907100: object=_UIStatusBarIndicatorAssistantItem>>";
- "<_UIStatusBarIdentifier: 0x600001907620: object=_UIStatusBarBatteryItem>" = "<_UIStatusBarBatteryItem: 0x600003b7f4d0: identifier=<_UIStatusBarIdentifier: 0x600001907620: object=_UIStatusBarBatteryItem>>";
- "<_UIStatusBarIdentifier: 0x600001903de0: object=_UIStatusBarNavigationItem>" = "<_UIStatusBarNavigationItem: 0x60000177fc90: identifier=<_UIStatusBarIdentifier: 0x600001903de0: object=_UIStatusBarNavigationItem>>";
- "<_UIStatusBarIdentifier: 0x600001907180: object=_UIStatusBarIndicatorAirPlayItem>" = "<_UIStatusBarIndicatorAirPlayItem: 0x6000003b1d00: identifier=<_UIStatusBarIdentifier: 0x600001907180: object=_UIStatusBarIndicatorAirPlayItem>>";
- "<_UIStatusBarIdentifier: 0x600001906c60: object=_UIStatusBarWifiItem>" = "<_UIStatusBarWifiItem: 0x6000003b2480: identifier=<_UIStatusBarIdentifier: 0x600001906c60: object=_UIStatusBarWifiItem>>";
- "<_UIStatusBarIdentifier: 0x600001903b60: object=_UIStatusBarVoiceControlItem>" = "<_UIStatusBarVoiceControlItem: 0x6000003b1f80: identifier=<_UIStatusBarIdentifier: 0x600001903b60: object=_UIStatusBarVoiceControlItem>>";
- "<_UIStatusBarIdentifier: 0x600001907200: object=_UIStatusBarIndicatorCarPlayItem>" = "<_UIStatusBarIndicatorCarPlayItem: 0x6000003b1d80: identifier=<_UIStatusBarIdentifier: 0x600001907200: object=_UIStatusBarIndicatorCarPlayItem>>";
- "<_UIStatusBarIdentifier: 0x600001903be0: object=_UIStatusBarPillBackgroundActivityItem>" = "<_UIStatusBarPillBackgroundActivityItem: 0x600003c4d560: identifier=<_UIStatusBarIdentifier: 0x600001903be0: object=_UIStatusBarPillBackgroundActivityItem>>";
- "<_UIStatusBarIdentifier: 0x600001906b20: object=_UIStatusBarCellularExpandedItem>" = "<_UIStatusBarCellularExpandedItem: 0x60000366c280: identifier=<_UIStatusBarIdentifier: 0x600001906b20: object=_UIStatusBarCellularExpandedItem>>";
- "<_UIStatusBarIdentifier: 0x600001907280: object=_UIStatusBarIndicatorStudentItem>" = "<_UIStatusBarIndicatorStudentItem: 0x6000003b1dc0: identifier=<_UIStatusBarIdentifier: 0x600001907280: object=_UIStatusBarIndicatorStudentItem>>";
- }
- (lldb) po [statusBar performSelector:@selector(containerView)]
- <_UIStatusBarForegroundView: 0x7fee31804f30; frame = (0 0; 375 44); layer = <CALayer: 0x600001907720>>
- (lldb) po [statusBar performSelector:@selector(setForegroundColor:) withObject:[UIColor whiteColor]]
- UICachedDeviceWhiteColor
- (lldb) po [statusBar performSelector:@selector(styleAttributes)]
- <_UIStatusBarStyleAttributes: 0x60000332fd40: style=-6485417468062910266, mode=-6485417468062910314, traitCollection=<UITraitCollection: 0x600002db61c0; UserInterfaceIdiom = Phone, DisplayScale = 2, DisplayGamut = P3, HorizontalSizeClass = Compact, VerticalSizeClass = Compact, UserInterfaceStyle = Light, UserInterfaceLayoutDirection = LTR, ForceTouchCapability = Unavailable, PreferredContentSizeCategory = L, AccessibilityContrast = Normal, UserInterfaceLevel = Base>, effectiveLayoutDirection=0, iconScale=1, symbolScale=1, textColor=UIExtendedGrayColorSpace 1 1, imageTintColor=UIExtendedGrayColorSpace 1 1, imageDimmedTintColor=UIExtendedGrayColorSpace 1 0.2, imageNamePrefixes=(
- "Split_",
- "Black_",
- "Item_"
- )>
来源: http://www.jianshu.com/p/d2a0fa7bcbef