Toggle navigation
Toggle navigation
This project
Loading...
Sign in
ios
/
yh_sdwebimage
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
iwill
8 years ago
Commit
de897ae33a79f72fad12a75f22fb43ab8db580c6
1 parent
80dace4a
Fix issue #2001
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
8 deletions
SDWebImage/UIButton+WebCache.m
SDWebImage/UIButton+WebCache.m
View file @
de897ae
...
...
@@ -16,10 +16,14 @@
static
char
imageURLStorageKey
;
typedef
NSMutableDictionary
<
NS
Number
*
,
NSURL
*>
SDStateImageURLDictionary
;
typedef
NSMutableDictionary
<
NS
String
*
,
NSURL
*>
SDStateImageURLDictionary
;
static
inline
NSNumber
*
backgroundImageURLKeyForState
(
UIControlState
state
)
{
return
@
(
NSUIntegerMax
-
state
-
1
);
static
inline
NSString
*
imageURLKeyForState
(
UIControlState
state
)
{
return
[
NSString
stringWithFormat
:
@"image_%lu"
,
(
unsigned
long
)
state
];
}
static
inline
NSString
*
backgroundImageURLKeyForState
(
UIControlState
state
)
{
return
[
NSString
stringWithFormat
:
@"backgroundImage_%lu"
,
(
unsigned
long
)
state
];
}
@implementation
UIButton
(
WebCache
)
...
...
@@ -27,17 +31,17 @@ static inline NSNumber * backgroundImageURLKeyForState(UIControlState state) {
#pragma mark - Image
-
(
nullable
NSURL
*
)
sd_currentImageURL
{
NSURL
*
url
=
self
.
imageURLStorage
[
@
(
self
.
state
)];
NSURL
*
url
=
self
.
imageURLStorage
[
imageURLKeyForState
(
self
.
state
)];
if
(
!
url
)
{
url
=
self
.
imageURLStorage
[
@
(
UIControlStateNormal
)];
url
=
self
.
imageURLStorage
[
imageURLKeyForState
(
UIControlStateNormal
)];
}
return
url
;
}
-
(
nullable
NSURL
*
)
sd_imageURLForState
:
(
UIControlState
)
state
{
return
self
.
imageURLStorage
[
@
(
state
)];
return
self
.
imageURLStorage
[
imageURLKeyForState
(
state
)];
}
-
(
void
)
sd_setImageWithURL
:
(
nullable
NSURL
*
)
url
forState
:
(
UIControlState
)
state
{
...
...
@@ -66,11 +70,11 @@ static inline NSNumber * backgroundImageURLKeyForState(UIControlState state) {
options
:
(
SDWebImageOptions
)
options
completed
:
(
nullable
SDExternalCompletionBlock
)
completedBlock
{
if
(
!
url
)
{
[
self
.
imageURLStorage
removeObjectForKey
:
@
(
state
)];
[
self
.
imageURLStorage
removeObjectForKey
:
imageURLKeyForState
(
state
)];
return
;
}
self
.
imageURLStorage
[
@
(
state
)]
=
url
;
self
.
imageURLStorage
[
imageURLKeyForState
(
state
)]
=
url
;
__weak
typeof
(
self
)
weakSelf
=
self
;
[
self
sd_internalSetImageWithURL
:
url
...
...
Please
register
or
login
to post a comment