初始化
UIImageView *imgView = [[UIImageView alloc] init];
// 带有默认size,size = 图片的大小
UIImageView *imgView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"001"]];
@class UIImage;
//
//NS_CLASS_AVAILABLE_IOS(2_0) @interface UIImageView : UIView
//
- (instancetype)initWithImage:(nullable UIImage *)image;
- (instancetype)initWithImage:(nullable UIImage *)image highlightedImage:(nullable UIImage *)highlightedImage NS_AVAILABLE_IOS(3_0);
//
@property (nullable, nonatomic, strong) UIImage *image; // default is nil
@property (nullable, nonatomic, strong) UIImage *highlightedImage NS_AVAILABLE_IOS(3_0); // default is nil
@property (nonatomic, getter=isUserInteractionEnabled) BOOL userInteractionEnabled; // default is NO
//
@property (nonatomic, getter=isHighlighted) BOOL highlighted NS_AVAILABLE_IOS(3_0); // default is NO
//
//// these allow a set of images to be animated. the array may contain multiple copies of the same
//
@property (nullable, nonatomic, copy) NSArray<UIImage *> *animationImages; // The array must contain UIImages. Setting hides the single image. default is nil
@property (nullable, nonatomic, copy) NSArray<UIImage *> *highlightedAnimationImages NS_AVAILABLE_IOS(3_0); // The array must contain UIImages. Setting hides the single image. default is nil
//
@property (nonatomic) NSTimeInterval animationDuration; // for one cycle of images. default is number of images * 1/30th of a second (i.e. 30 fps)
@property (nonatomic) NSInteger animationRepeatCount; // 0 means infinite (default is 0)
//
//// When tintColor is non-nil, any template images set on the image view will be colorized with that color.
//// The tintColor is inherited through the superview hierarchy. See UIView for more information.
@property (null_resettable, nonatomic, strong) UIColor *tintColor NS_AVAILABLE_IOS(7_0);
UIImage *img2 = [UIImage imageNamed:@"iconfont-xingxing (2)"];
imgView.tintColor = [UIColor redColor];
img2 = [img2 imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
imgView.image = img2;
黑色为原图片颜色,红色为tintColor的颜色。
//
- (void)startAnimating;
- (void)stopAnimating;
- (BOOL)isAnimating;
//
//// if YES, the UIImageView will display a focused appearance when any of its immediate or distant superviews become focused
@property (nonatomic) BOOL adjustsImageWhenAncestorFocused UIKIT_AVAILABLE_TVOS_ONLY(9_0);
//
//// if adjustsImageWhenAncestorFocused is set, the image view may display its image in a larger frame when focused.
//// this layout guide can be used to align other elements with the image view's focused frame.
@property(readonly,strong) UILayoutGuide *focusedFrameGuide UIKIT_AVAILABLE_TVOS_ONLY(9_0);
//
@end