Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
D
dz_TZImagePickerController
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
shuijing
dz_TZImagePickerController
Commits
c4f53fa8
Commit
c4f53fa8
authored
Oct 15, 2020
by
yuzheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
适配iPhone12,使用safeAreaInsets升级iPhoneX系列手机适配方式
parent
74da94c1
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
37 additions
and
11 deletions
+37
-11
TZImagePickerController/TZImagePickerController/TZGifPhotoPreviewController.m
...ler/TZImagePickerController/TZGifPhotoPreviewController.m
+1
-1
TZImagePickerController/TZImagePickerController/TZImagePickerController.h
...troller/TZImagePickerController/TZImagePickerController.h
+1
-0
TZImagePickerController/TZImagePickerController/TZImagePickerController.m
...troller/TZImagePickerController/TZImagePickerController.m
+27
-2
TZImagePickerController/TZImagePickerController/TZPhotoPickerController.m
...troller/TZImagePickerController/TZPhotoPickerController.m
+1
-1
TZImagePickerController/TZImagePickerController/TZPhotoPreviewCell.m
...erController/TZImagePickerController/TZPhotoPreviewCell.m
+4
-4
TZImagePickerController/TZImagePickerController/TZPhotoPreviewController.m
...roller/TZImagePickerController/TZPhotoPreviewController.m
+1
-1
TZImagePickerController/TZImagePickerController/TZVideoPlayerController.m
...troller/TZImagePickerController/TZVideoPlayerController.m
+2
-2
No files found.
TZImagePickerController/TZImagePickerController/TZGifPhotoPreviewController.m
View file @
c4f53fa8
...
...
@@ -116,7 +116,7 @@
_previewView
.
frame
=
self
.
view
.
bounds
;
_previewView
.
scrollView
.
frame
=
self
.
view
.
bounds
;
CGFloat
toolBarHeight
=
[
TZCommonTools
tz_isIPhoneX
]
?
44
+
(
83
-
49
)
:
44
;
CGFloat
toolBarHeight
=
44
+
[
TZCommonTools
tz_safeAreaInsets
].
bottom
;
_toolBar
.
frame
=
CGRectMake
(
0
,
self
.
view
.
tz_height
-
toolBarHeight
,
self
.
view
.
tz_width
,
toolBarHeight
);
_doneButton
.
frame
=
CGRectMake
(
self
.
view
.
tz_width
-
44
-
12
,
0
,
44
,
44
);
...
...
TZImagePickerController/TZImagePickerController/TZImagePickerController.h
View file @
c4f53fa8
...
...
@@ -305,6 +305,7 @@
@interface
TZCommonTools
:
NSObject
+
(
UIEdgeInsets
)
tz_safeAreaInsets
;
+
(
BOOL
)
tz_isIPhoneX
;
+
(
CGFloat
)
tz_statusBarHeight
;
// 获得Info.plist数据字典
...
...
TZImagePickerController/TZImagePickerController/TZImagePickerController.m
View file @
c4f53fa8
...
...
@@ -905,15 +905,40 @@
@implementation
TZCommonTools
+
(
UIEdgeInsets
)
tz_safeAreaInsets
{
UIWindow
*
window
=
[
UIApplication
sharedApplication
].
windows
.
firstObject
;
if
(
!
[
window
isKeyWindow
])
{
UIWindow
*
keyWindow
=
[
UIApplication
sharedApplication
].
keyWindow
;
if
(
CGRectEqualToRect
(
keyWindow
.
bounds
,
[
UIScreen
mainScreen
].
bounds
))
{
window
=
keyWindow
;
}
}
if
(
@available
(
iOS
11
.
0
,
*
))
{
UIEdgeInsets
insets
=
[
window
safeAreaInsets
];
return
insets
;
}
return
UIEdgeInsetsZero
;
}
+
(
BOOL
)
tz_isIPhoneX
{
if
([
UIWindow
instancesRespondToSelector
:
@selector
(
safeAreaInsets
)])
{
return
[
self
tz_safeAreaInsets
].
bottom
>
0
;
}
return
(
CGSizeEqualToSize
([
UIScreen
mainScreen
].
bounds
.
size
,
CGSizeMake
(
375
,
812
))
||
CGSizeEqualToSize
([
UIScreen
mainScreen
].
bounds
.
size
,
CGSizeMake
(
812
,
375
))
||
CGSizeEqualToSize
([
UIScreen
mainScreen
].
bounds
.
size
,
CGSizeMake
(
414
,
896
))
||
CGSizeEqualToSize
([
UIScreen
mainScreen
].
bounds
.
size
,
CGSizeMake
(
896
,
414
)));
CGSizeEqualToSize
([
UIScreen
mainScreen
].
bounds
.
size
,
CGSizeMake
(
896
,
414
))
||
CGSizeEqualToSize
([
UIScreen
mainScreen
].
bounds
.
size
,
CGSizeMake
(
390
,
844
))
||
CGSizeEqualToSize
([
UIScreen
mainScreen
].
bounds
.
size
,
CGSizeMake
(
844
,
390
))
||
CGSizeEqualToSize
([
UIScreen
mainScreen
].
bounds
.
size
,
CGSizeMake
(
428
,
926
))
||
CGSizeEqualToSize
([
UIScreen
mainScreen
].
bounds
.
size
,
CGSizeMake
(
926
,
428
)));
}
+
(
CGFloat
)
tz_statusBarHeight
{
return
[
self
tz_isIPhoneX
]
?
44
:
20
;
if
([
UIWindow
instancesRespondToSelector
:
@selector
(
safeAreaInsets
)])
{
return
[
self
tz_safeAreaInsets
].
top
;
}
return
20
;
}
// 获得Info.plist数据字典
...
...
TZImagePickerController/TZImagePickerController/TZPhotoPickerController.m
View file @
c4f53fa8
...
...
@@ -349,7 +349,7 @@ static CGFloat itemMargin = 5;
CGFloat
naviBarHeight
=
self
.
navigationController
.
navigationBar
.
tz_height
;
BOOL
isStatusBarHidden
=
[
UIApplication
sharedApplication
].
isStatusBarHidden
;
BOOL
isFullScreen
=
self
.
view
.
tz_height
==
[
UIScreen
mainScreen
].
bounds
.
size
.
height
;
CGFloat
toolBarHeight
=
[
TZCommonTools
tz_isIPhoneX
]
?
50
+
(
83
-
49
)
:
50
;
CGFloat
toolBarHeight
=
50
+
[
TZCommonTools
tz_safeAreaInsets
].
bottom
;
if
(
self
.
navigationController
.
navigationBar
.
isTranslucent
)
{
top
=
naviBarHeight
;
if
(
!
isStatusBarHidden
&&
isFullScreen
)
top
+=
[
TZCommonTools
tz_statusBarHeight
];
...
...
TZImagePickerController/TZImagePickerController/TZPhotoPreviewCell.m
View file @
c4f53fa8
...
...
@@ -342,8 +342,8 @@
CGFloat
progressY
=
(
self
.
tz_height
-
progressWH
)
/
2
;
_progressView
.
frame
=
CGRectMake
(
progressX
,
progressY
,
progressWH
,
progressWH
);
[
self
recoverSubviews
];
_iCloudErrorIcon
.
frame
=
CGRectMake
(
20
,
[
TZCommonTools
tz_
isIPhoneX
]
?
88
+
10
:
6
4
+
10
,
28
,
28
);
_iCloudErrorLabel
.
frame
=
CGRectMake
(
53
,
[
TZCommonTools
tz_
isIPhoneX
]
?
88
+
10
:
6
4
+
10
,
self
.
tz_width
-
63
,
28
);
_iCloudErrorIcon
.
frame
=
CGRectMake
(
20
,
[
TZCommonTools
tz_
statusBarHeight
]
+
4
4
+
10
,
28
,
28
);
_iCloudErrorLabel
.
frame
=
CGRectMake
(
53
,
[
TZCommonTools
tz_
statusBarHeight
]
+
4
4
+
10
,
self
.
tz_width
-
63
,
28
);
}
#pragma mark - UITapGestureRecognizer Event
...
...
@@ -484,8 +484,8 @@
[
super
layoutSubviews
];
_playerLayer
.
frame
=
self
.
bounds
;
_playButton
.
frame
=
CGRectMake
(
0
,
64
,
self
.
tz_width
,
self
.
tz_height
-
64
-
44
);
_iCloudErrorIcon
.
frame
=
CGRectMake
(
20
,
[
TZCommonTools
tz_
isIPhoneX
]
?
88
+
10
:
6
4
+
10
,
28
,
28
);
_iCloudErrorLabel
.
frame
=
CGRectMake
(
53
,
[
TZCommonTools
tz_
isIPhoneX
]
?
88
+
10
:
6
4
+
10
,
self
.
tz_width
-
63
,
28
);
_iCloudErrorIcon
.
frame
=
CGRectMake
(
20
,
[
TZCommonTools
tz_
statusBarHeight
]
+
4
4
+
10
,
28
,
28
);
_iCloudErrorLabel
.
frame
=
CGRectMake
(
53
,
[
TZCommonTools
tz_
statusBarHeight
]
+
4
4
+
10
,
self
.
tz_width
-
63
,
28
);
}
-
(
void
)
photoPreviewCollectionViewDidScroll
{
...
...
TZImagePickerController/TZImagePickerController/TZPhotoPreviewController.m
View file @
c4f53fa8
...
...
@@ -275,7 +275,7 @@
[
_collectionView
reloadData
];
}
CGFloat
toolBarHeight
=
[
TZCommonTools
tz_isIPhoneX
]
?
44
+
(
83
-
49
)
:
44
;
CGFloat
toolBarHeight
=
44
+
[
TZCommonTools
tz_safeAreaInsets
].
bottom
;
CGFloat
toolBarTop
=
self
.
view
.
tz_height
-
toolBarHeight
;
_toolBar
.
frame
=
CGRectMake
(
0
,
toolBarTop
,
self
.
view
.
tz_width
,
toolBarHeight
);
if
(
_tzImagePickerVc
.
allowPickingOriginalPhoto
)
{
...
...
TZImagePickerController/TZImagePickerController/TZVideoPlayerController.m
View file @
c4f53fa8
...
...
@@ -153,7 +153,7 @@
CGFloat
statusBarHeight
=
isFullScreen
?
[
TZCommonTools
tz_statusBarHeight
]
:
0
;
CGFloat
statusBarAndNaviBarHeight
=
statusBarHeight
+
self
.
navigationController
.
navigationBar
.
tz_height
;
_playerLayer
.
frame
=
self
.
view
.
bounds
;
CGFloat
toolBarHeight
=
[
TZCommonTools
tz_isIPhoneX
]
?
44
+
(
83
-
49
)
:
44
;
CGFloat
toolBarHeight
=
44
+
[
TZCommonTools
tz_safeAreaInsets
].
bottom
;
_toolBar
.
frame
=
CGRectMake
(
0
,
self
.
view
.
tz_height
-
toolBarHeight
,
self
.
view
.
tz_width
,
toolBarHeight
);
_doneButton
.
frame
=
CGRectMake
(
self
.
view
.
tz_width
-
44
-
12
,
0
,
44
,
44
);
_playButton
.
frame
=
CGRectMake
(
0
,
statusBarAndNaviBarHeight
,
self
.
view
.
tz_width
,
self
.
view
.
tz_height
-
statusBarAndNaviBarHeight
-
toolBarHeight
);
...
...
@@ -224,7 +224,7 @@
#pragma mark - lazy
-
(
UIView
*
)
iCloudErrorView
{
if
(
!
_iCloudErrorView
)
{
_iCloudErrorView
=
[[
UIView
alloc
]
initWithFrame
:
CGRectMake
(
0
,
[
TZCommonTools
tz_
isIPhoneX
]
?
88
+
10
:
6
4
+
10
,
self
.
view
.
tz_width
,
28
)];
_iCloudErrorView
=
[[
UIView
alloc
]
initWithFrame
:
CGRectMake
(
0
,
[
TZCommonTools
tz_
statusBarHeight
]
+
4
4
+
10
,
self
.
view
.
tz_width
,
28
)];
UIImageView
*
icloud
=
[[
UIImageView
alloc
]
init
];
icloud
.
image
=
[
UIImage
tz_imageNamedFromMyBundle
:
@"iCloudError"
];
icloud
.
frame
=
CGRectMake
(
20
,
0
,
28
,
28
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment