123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210 |
- //
- // UIButton+YYWebImage.h
- // YYWebImage <https://github.com/ibireme/YYWebImage>
- //
- // Created by ibireme on 15/2/23.
- // Copyright (c) 2015 ibireme.
- //
- // This source code is licensed under the MIT-style license found in the
- // LICENSE file in the root directory of this source tree.
- //
- #import <UIKit/UIKit.h>
- #if __has_include(<YYWebImage/YYWebImage.h>)
- #import <YYWebImage/YYWebImageManager.h>
- #else
- #import "YYWebImageManager.h"
- #endif
- /**
- Web image methods for UIButton.
- */
- @interface UIButton (YYWebImage)
- #pragma mark - image
- /**
- Current image URL for the specified state.
- @return The image URL, or nil.
- */
- - (NSURL *)yy_imageURLForState:(UIControlState)state;
- /**
- Set the button's image with a specified URL for the specified state.
-
- @param imageURL The image url (remote or local file path).
- @param state The state that uses the specified image.
- @param placeholder The image to be set initially, until the image request finishes.
- */
- - (void)yy_setImageWithURL:(NSURL *)imageURL
- forState:(UIControlState)state
- placeholder:(UIImage *)placeholder;
- /**
- Set the button's image with a specified URL for the specified state.
-
- @param imageURL The image url (remote or local file path).
- @param state The state that uses the specified image.
- @param options The options to use when request the image.
- */
- - (void)yy_setImageWithURL:(NSURL *)imageURL
- forState:(UIControlState)state
- options:(YYWebImageOptions)options;
- /**
- Set the button's image with a specified URL for the specified state.
-
- @param imageURL The image url (remote or local file path).
- @param state The state that uses the specified image.
- @param placeholder The image to be set initially, until the image request finishes.
- @param options The options to use when request the image.
- @param completion The block invoked (on main thread) when image request completed.
- */
- - (void)yy_setImageWithURL:(NSURL *)imageURL
- forState:(UIControlState)state
- placeholder:(UIImage *)placeholder
- options:(YYWebImageOptions)options
- completion:(YYWebImageCompletionBlock)completion;
- /**
- Set the button's image with a specified URL for the specified state.
-
- @param imageURL The image url (remote or local file path).
- @param state The state that uses the specified image.
- @param placeholder The image to be set initially, until the image request finishes.
- @param options The options to use when request the image.
- @param progress The block invoked (on main thread) during image request.
- @param transform The block invoked (on background thread) to do additional image process.
- @param completion The block invoked (on main thread) when image request completed.
- */
- - (void)yy_setImageWithURL:(NSURL *)imageURL
- forState:(UIControlState)state
- placeholder:(UIImage *)placeholder
- options:(YYWebImageOptions)options
- progress:(YYWebImageProgressBlock)progress
- transform:(YYWebImageTransformBlock)transform
- completion:(YYWebImageCompletionBlock)completion;
- /**
- Set the button's image with a specified URL for the specified state.
-
- @param imageURL The image url (remote or local file path).
- @param state The state that uses the specified image.
- @param placeholder The image to be set initially, until the image request finishes.
- @param options The options to use when request the image.
- @param manager The manager to create image request operation.
- @param progress The block invoked (on main thread) during image request.
- @param transform The block invoked (on background thread) to do additional image process.
- @param completion The block invoked (on main thread) when image request completed.
- */
- - (void)yy_setImageWithURL:(NSURL *)imageURL
- forState:(UIControlState)state
- placeholder:(UIImage *)placeholder
- options:(YYWebImageOptions)options
- manager:(YYWebImageManager *)manager
- progress:(YYWebImageProgressBlock)progress
- transform:(YYWebImageTransformBlock)transform
- completion:(YYWebImageCompletionBlock)completion;
- /**
- Cancel the current image request for a specified state.
- @param state The state that uses the specified image.
- */
- - (void)yy_cancelImageRequestForState:(UIControlState)state;
- #pragma mark - background image
- /**
- Current backgroundImage URL for the specified state.
- @return The image URL, or nil.
- */
- - (NSURL *)yy_backgroundImageURLForState:(UIControlState)state;
- /**
- Set the button's backgroundImage with a specified URL for the specified state.
-
- @param imageURL The image url (remote or local file path).
- @param state The state that uses the specified image.
- @param placeholder The image to be set initially, until the image request finishes.
- */
- - (void)yy_setBackgroundImageWithURL:(NSURL *)imageURL
- forState:(UIControlState)state
- placeholder:(UIImage *)placeholder;
- /**
- Set the button's backgroundImage with a specified URL for the specified state.
-
- @param imageURL The image url (remote or local file path).
- @param state The state that uses the specified image.
- @param options The options to use when request the image.
- */
- - (void)yy_setBackgroundImageWithURL:(NSURL *)imageURL
- forState:(UIControlState)state
- options:(YYWebImageOptions)options;
- /**
- Set the button's backgroundImage with a specified URL for the specified state.
-
- @param imageURL The image url (remote or local file path).
- @param state The state that uses the specified image.
- @param placeholder The image to be set initially, until the image request finishes.
- @param options The options to use when request the image.
- @param completion The block invoked (on main thread) when image request completed.
- */
- - (void)yy_setBackgroundImageWithURL:(NSURL *)imageURL
- forState:(UIControlState)state
- placeholder:(UIImage *)placeholder
- options:(YYWebImageOptions)options
- completion:(YYWebImageCompletionBlock)completion;
- /**
- Set the button's backgroundImage with a specified URL for the specified state.
-
- @param imageURL The image url (remote or local file path).
- @param state The state that uses the specified image.
- @param placeholder The image to be set initially, until the image request finishes.
- @param options The options to use when request the image.
- @param progress The block invoked (on main thread) during image request.
- @param transform The block invoked (on background thread) to do additional image process.
- @param completion The block invoked (on main thread) when image request completed.
- */
- - (void)yy_setBackgroundImageWithURL:(NSURL *)imageURL
- forState:(UIControlState)state
- placeholder:(UIImage *)placeholder
- options:(YYWebImageOptions)options
- progress:(YYWebImageProgressBlock)progress
- transform:(YYWebImageTransformBlock)transform
- completion:(YYWebImageCompletionBlock)completion;
- /**
- Set the button's backgroundImage with a specified URL for the specified state.
-
- @param imageURL The image url (remote or local file path).
- @param state The state that uses the specified image.
- @param placeholder The image to be set initially, until the image request finishes.
- @param options The options to use when request the image.
- @param manager The manager to create image request operation.
- @param progress The block invoked (on main thread) during image request.
- @param transform The block invoked (on background thread) to do additional image process.
- @param completion The block invoked (on main thread) when image request completed.
- */
- - (void)yy_setBackgroundImageWithURL:(NSURL *)imageURL
- forState:(UIControlState)state
- placeholder:(UIImage *)placeholder
- options:(YYWebImageOptions)options
- manager:(YYWebImageManager *)manager
- progress:(YYWebImageProgressBlock)progress
- transform:(YYWebImageTransformBlock)transform
- completion:(YYWebImageCompletionBlock)completion;
- /**
- Cancel the current backgroundImage request for a specified state.
- @param state The state that uses the specified image.
- */
- - (void)yy_cancelBackgroundImageRequestForState:(UIControlState)state;
- @end
|