Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
galaxy-iOS
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mobile-group
galaxy-iOS
Commits
84f3b544
Commit
84f3b544
authored
Oct 14, 2025
by
Alex朱枝文
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化扫码动画效果
parent
358f08bd
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
92 additions
and
25 deletions
+92
-25
LBXScanLineAnimation.swift
...galaxy/Classes/Tools/SwiftScan/LBXScanLineAnimation.swift
+41
-10
LBXScanNetAnimation.swift
.../galaxy/Classes/Tools/SwiftScan/LBXScanNetAnimation.swift
+45
-10
LBXScanViewController.swift
...alaxy/Classes/Tools/SwiftScan/LBXScanViewController.swift
+6
-5
No files found.
galaxy/galaxy/Classes/Tools/SwiftScan/LBXScanLineAnimation.swift
View file @
84f3b544
...
...
@@ -25,7 +25,6 @@ class LBXScanLineAnimation: UIImageView {
if
image
!=
nil
{
stepAnimation
()
}
}
@objc
func
stepAnimation
()
{
...
...
@@ -35,37 +34,69 @@ class LBXScanLineAnimation: UIImageView {
guard
let
image
=
self
.
image
else
{
return
}
// 重要:取消之前可能存在的延迟调用
NSObject
.
cancelPreviousPerformRequests
(
withTarget
:
self
,
selector
:
#selector(
LBXScanLineAnimation.stepAnimation
)
,
object
:
nil
)
var
frame
:
CGRect
=
animationRect
let
hImg
=
image
.
size
.
height
*
animationRect
.
size
.
width
/
image
.
size
.
width
frame
.
origin
.
y
-=
hImg
// 重置到起始位置
frame
.
origin
.
y
=
animationRect
.
origin
.
y
frame
.
size
.
height
=
hImg
self
.
frame
=
frame
self
.
alpha
=
0.0
UIView
.
animate
(
withDuration
:
1.4
,
animations
:
{
()
in
UIView
.
animate
(
withDuration
:
1.4
,
animations
:
{
[
weak
self
]
()
in
guard
let
self
=
self
else
{
return
}
self
.
alpha
=
1.0
var
frame
=
self
.
animationRect
let
hImg
=
image
.
size
.
height
*
self
.
animationRect
.
size
.
width
/
image
.
size
.
width
frame
.
origin
.
y
+=
(
frame
.
size
.
height
-
hImg
)
frame
.
origin
.
y
=
self
.
animationRect
.
origin
.
y
+
(
self
.
animationRect
.
size
.
height
-
hImg
)
frame
.
size
.
height
=
hImg
self
.
frame
=
frame
},
completion
:
{
(
_
:
Bool
)
in
},
completion
:
{
[
weak
self
]
(
_
:
Bool
)
in
guard
let
self
=
self
else
{
return
}
self
.
perform
(
#selector(
LBXScanLineAnimation.stepAnimation
)
,
with
:
nil
,
afterDelay
:
0.3
)
// 检查动画是否应该继续
if
self
.
isAnimationing
{
self
.
perform
(
#selector(
LBXScanLineAnimation.stepAnimation
)
,
with
:
nil
,
afterDelay
:
0.3
)
}
})
}
func
stopStepAnimating
()
{
self
.
isHidden
=
true
// 先设置标记为false,阻止新的动画开始
isAnimationing
=
false
// 取消所有延迟调用
NSObject
.
cancelPreviousPerformRequests
(
withTarget
:
self
)
// 停止当前的动画
self
.
layer
.
removeAllAnimations
()
// 隐藏视图
self
.
isHidden
=
true
// 重置frame到初始位置
if
!
animationRect
.
isEmpty
{
var
frame
=
animationRect
if
let
image
=
self
.
image
{
let
hImg
=
image
.
size
.
height
*
animationRect
.
size
.
width
/
image
.
size
.
width
frame
.
origin
.
y
=
animationRect
.
origin
.
y
frame
.
size
.
height
=
hImg
}
self
.
frame
=
frame
}
}
static
public
func
instance
()
->
LBXScanLineAnimation
{
...
...
@@ -73,7 +104,7 @@ class LBXScanLineAnimation: UIImageView {
}
deinit
{
NSObject
.
cancelPreviousPerformRequests
(
withTarget
:
self
)
stopStepAnimating
()
}
}
galaxy/galaxy/Classes/Tools/SwiftScan/LBXScanNetAnimation.swift
View file @
84f3b544
...
...
@@ -38,39 +38,74 @@ class LBXScanNetAnimation: UIImageView {
guard
let
image
=
self
.
image
else
{
return
}
// 重要:取消之前可能存在的延迟调用
NSObject
.
cancelPreviousPerformRequests
(
withTarget
:
self
,
selector
:
#selector(
LBXScanNetAnimation.stepAnimation
)
,
object
:
nil
)
var
frame
=
animationRect
let
hImg
=
image
.
size
.
height
*
animationRect
.
size
.
width
/
image
.
size
.
width
frame
.
origin
.
y
-=
hImg
// 重置到起始位置
frame
.
origin
.
y
=
animationRect
.
origin
.
y
frame
.
size
.
height
=
hImg
self
.
frame
=
frame
self
.
alpha
=
0.0
UIView
.
animate
(
withDuration
:
1.2
,
animations
:
{
()
in
UIView
.
animate
(
withDuration
:
1.2
,
animations
:
{
[
weak
self
]
()
in
guard
let
self
=
self
else
{
return
}
self
.
alpha
=
1.0
var
frame
=
self
.
animationRect
let
hImg
=
image
.
size
.
height
*
self
.
animationRect
.
size
.
width
/
image
.
size
.
width
frame
.
origin
.
y
+=
(
frame
.
size
.
height
-
hImg
)
frame
.
origin
.
y
=
self
.
animationRect
.
origin
.
y
+
(
self
.
animationRect
.
size
.
height
-
hImg
)
frame
.
size
.
height
=
hImg
self
.
frame
=
frame
},
completion
:
{
(
_
:
Bool
)
in
self
.
perform
(
#selector(
LBXScanNetAnimation.stepAnimation
)
,
with
:
nil
,
afterDelay
:
0.3
)
},
completion
:
{
[
weak
self
]
(
_
:
Bool
)
in
guard
let
self
=
self
else
{
return
}
// 检查动画是否应该继续
if
self
.
isAnimationing
{
self
.
perform
(
#selector(
LBXScanNetAnimation.stepAnimation
)
,
with
:
nil
,
afterDelay
:
0.3
)
}
})
}
func
stopStepAnimating
()
{
self
.
isHidden
=
true
// 先设置标记为false,阻止新的动画开始
isAnimationing
=
false
// 取消所有延迟调用
NSObject
.
cancelPreviousPerformRequests
(
withTarget
:
self
)
// 停止当前的动画
self
.
layer
.
removeAllAnimations
()
// 隐藏视图
self
.
isHidden
=
true
// 重置frame到初始位置
if
!
animationRect
.
isEmpty
{
var
frame
=
animationRect
if
let
image
=
self
.
image
{
let
hImg
=
image
.
size
.
height
*
animationRect
.
size
.
width
/
image
.
size
.
width
frame
.
origin
.
y
=
animationRect
.
origin
.
y
frame
.
size
.
height
=
hImg
}
self
.
frame
=
frame
}
}
deinit
{
NSObject
.
cancelPreviousPerformRequests
(
withTarget
:
self
)
stopStepAnimating
()
}
}
galaxy/galaxy/Classes/Tools/SwiftScan/LBXScanViewController.swift
View file @
84f3b544
...
...
@@ -81,6 +81,12 @@ class LBXScanViewController: YHBaseViewController, UIImagePickerControllerDelega
}
}
override
open
func
viewWillDisappear
(
_
animated
:
Bool
)
{
super
.
viewWillDisappear
(
animated
)
NSObject
.
cancelPreviousPerformRequests
(
withTarget
:
self
)
stopScan
()
}
@objc
open
func
startScan
()
{
if
scanObj
==
nil
{
var
cropRect
=
CGRect
.
zero
...
...
@@ -161,11 +167,6 @@ class LBXScanViewController: YHBaseViewController, UIImagePickerControllerDelega
}
}
override
open
func
viewWillDisappear
(
_
animated
:
Bool
)
{
NSObject
.
cancelPreviousPerformRequests
(
withTarget
:
self
)
stopScan
()
}
open
func
openPhotoAlbum
()
{
LBXPermissions
.
authorizePhotoWith
{
[
weak
self
]
granted
in
if
granted
{
...
...
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