Skip to content

Commit

Permalink
adapt to iOS 9
Browse files Browse the repository at this point in the history
adapt to iOS 9
  • Loading branch information
CoderMJLee committed Sep 22, 2015
1 parent 41ca753 commit f2c0a03
Show file tree
Hide file tree
Showing 44 changed files with 325 additions and 184 deletions.
294 changes: 160 additions & 134 deletions MJRefreshExample/MJRefreshExample.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Binary file not shown.
6 changes: 3 additions & 3 deletions MJRefreshExample/MJRefreshExample/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="7703" systemVersion="14F27" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="06B-cM-i4B">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="8191" systemVersion="14F27" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="06B-cM-i4B">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6711"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8154"/>
</dependencies>
<scenes>
<!--Tab Bar Controller-->
Expand Down Expand Up @@ -118,7 +118,7 @@
<nil key="highlightedColor"/>
</label>
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Subtitle" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="Iv7-PA-lBt">
<rect key="frame" x="15" y="25.5" width="41" height="13.5"/>
<rect key="frame" x="15" y="25.5" width="40.5" height="13.5"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="11"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
Expand Down
27 changes: 27 additions & 0 deletions MJRefreshExample/MJRefreshExample/Classes/First/MJExampleWindow.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//
// MJExampleWindow.m
// MJRefreshExample
//
// Created by MJ Lee on 15/8/17.
// Copyright (c) 2015年 小码哥. All rights reserved.
//

#import "MJExampleWindow.h"
#import "MJTempViewController.h"

@implementation MJExampleWindow

static UIWindow *window_;
+ (void)show
{
window_ = [[UIWindow alloc] init];
CGFloat width = 150;
CGFloat x = [UIScreen mainScreen].bounds.size.width - width - 10;
window_.frame = CGRectMake(x, 0, width, 25);
window_.windowLevel = UIWindowLevelAlert;
window_.hidden = NO;
window_.alpha = 0.5;
window_.rootViewController = [[MJTempViewController alloc] init];
window_.backgroundColor = [UIColor clearColor];
}
@end
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,4 @@ + (void)initialize
[navBar setTitleTextAttributes:@{UITextAttributeTextColor : [UIColor whiteColor]}];
#endif
}

#pragma mark 控制状态栏的样式
- (UIStatusBarStyle)preferredStatusBarStyle
{
return UIStatusBarStyleLightContent;
}
@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// MJTempViewController.h
// MJRefreshExample
//
// Created by MJ Lee on 15/9/22.
// Copyright © 2015年 小码哥. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface MJTempViewController : UIViewController

+ (instancetype)sharedInstance;

@property (assign, nonatomic) UIStatusBarStyle statusBarStyle;
@property (assign, nonatomic) BOOL statusBarHidden;

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
//
// MJTempViewController.m
// MJRefreshExample
//
// Created by MJ Lee on 15/9/22.
// Copyright © 2015年 小码哥. All rights reserved.
//

#import "MJTempViewController.h"

@interface MJTempViewController ()

@end

@implementation MJTempViewController
#pragma mark - 单例
static id instance_;

+ (instancetype)sharedInstance
{
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
instance_ = [[self alloc] init];
});
return instance_;
}

+ (instancetype)allocWithZone:(struct _NSZone *)zone
{
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
instance_ = [super allocWithZone:zone];
});
return instance_;
}

#pragma mark - 初始化
- (void)viewDidLoad {
[super viewDidLoad];

self.statusBarStyle = UIStatusBarStyleLightContent;

self.view.backgroundColor = [UIColor clearColor];

UISegmentedControl *control = [[UISegmentedControl alloc] initWithItems:@[@"示例1", @"示例2", @"示例3"]];
control.tintColor = [UIColor orangeColor];
control.frame = self.view.bounds;
control.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
control.selectedSegmentIndex = 0;
[control addTarget:self action:@selector(contorlSelect:) forControlEvents:UIControlEventValueChanged];
[self.view addSubview:control];
}

- (void)contorlSelect:(UISegmentedControl *)control
{
UIWindow *keyWindow = [UIApplication sharedApplication].keyWindow;
keyWindow.rootViewController = [keyWindow.rootViewController.storyboard instantiateViewControllerWithIdentifier:[NSString stringWithFormat:@"%zd", control.selectedSegmentIndex]];

if (control.selectedSegmentIndex == 0) {
self.statusBarStyle = UIStatusBarStyleLightContent;
self.statusBarHidden = NO;
} else if (control.selectedSegmentIndex == 1) {
self.statusBarHidden = YES;
} else if (control.selectedSegmentIndex == 2) {
self.statusBarStyle = UIStatusBarStyleDefault;
self.statusBarHidden = NO;
}
}

- (UIStatusBarStyle)preferredStatusBarStyle
{
return self.statusBarStyle;
}

- (BOOL)prefersStatusBarHidden
{
return self.statusBarHidden;
}

- (void)setStatusBarHidden:(BOOL)statusBarHidden
{
_statusBarHidden = statusBarHidden;

[self setNeedsStatusBarAppearanceUpdate];
}

- (void)setStatusBarStyle:(UIStatusBarStyle)statusBarStyle
{
_statusBarStyle = statusBarStyle;

[self setNeedsStatusBarAppearanceUpdate];
}

@end
37 changes: 0 additions & 37 deletions MJRefreshExample/MJRefreshExample/Classes/MJExampleWindow.m

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ @implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

return YES;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="5023" systemVersion="13A603" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="8191" systemVersion="14F27" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3733"/>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8154"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="MJTestViewController">
Expand All @@ -14,8 +15,6 @@
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<simulatedStatusBarMetrics key="simulatedStatusBarMetrics"/>
<simulatedScreenMetrics key="simulatedDestinationMetrics" type="retina4"/>
</view>
</objects>
</document>
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ - (void)viewWillAppear:(BOOL)animated
[super viewWillAppear:animated];

[self.navigationController setNavigationBarHidden:YES animated:YES];

[self setNeedsStatusBarAppearanceUpdate];
}

- (void)viewWillDisappear:(BOOL)animated
Expand Down
5 changes: 5 additions & 0 deletions MJRefreshExample/MJRefreshExample/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>UILaunchStoryboardName</key>
Expand Down
12 changes: 12 additions & 0 deletions MJRefreshExample/MJRefreshExample/PrefixHeader.pch
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//
// PrefixHeader.pch
// MJRefreshExample
//
// Created by MJ Lee on 15/9/22.
// Copyright © 2015年 小码哥. All rights reserved.
//

#ifndef PrefixHeader_pch
#define PrefixHeader_pch
#import "MJTempViewController.h"
#endif /* PrefixHeader_pch */

0 comments on commit f2c0a03

Please sign in to comment.