ASImageNode Class Reference

Inherits from ASControlNode : ASDisplayNode : ASDealloc2MainObject
Declared in ASImageNode.h

Overview

Supports cropping, tinting, and arbitrary image modification blocks.

  image

The image to display.

@property (nullable, nonatomic, strong) UIImage *image

Discussion

The node will efficiently display stretchable images by using the layer’s contentsCenter property. Non-stretchable images work too, of course.

Declared In

ASImageNode.h

  placeholderColor

The placeholder color.

@property (nullable, nonatomic, strong) UIColor *placeholderColor

Declared In

ASImageNode.h

  cropEnabled

Indicates whether efficient cropping of the receiver is enabled.

@property (nonatomic, assign, getter=isCropEnabled) BOOL cropEnabled

Discussion

Defaults to YES. See -setCropEnabled:recropImmediately:inBounds: for more information.

Declared In

ASImageNode.h

  forceUpscaling

Indicates that efficient downsizing of backing store should not be enabled.

@property (nonatomic, assign) BOOL forceUpscaling

Discussion

Defaults to NO. @see ASCroppedImageBackingSizeAndDrawRectInBounds for more information.

Declared In

ASImageNode.h

  forcedSize

Forces image to be rendered at forcedSize.

@property (nonatomic, assign) CGSize forcedSize

Discussion

Defaults to CGSizeZero to indicate that the forcedSize should not be used. Setting forcedSize to non-CGSizeZero will force the backing of the layer contents to be forcedSize (automatically adjusted for contentsSize).

Declared In

ASImageNode.h

– setCropEnabled:recropImmediately:inBounds:

Enables or disables efficient cropping.

- (void)setCropEnabled:(BOOL)cropEnabled recropImmediately:(BOOL)recropImmediately inBounds:(CGRect)cropBounds

Parameters

cropEnabled

YES to efficiently crop the receiver’s contents such that contents outside of its bounds are not included; NO otherwise.

recropImmediately

If the receiver has an image, YES to redisplay the receiver immediately; NO otherwise.

cropBounds

The bounds into which the receiver will be cropped. Useful if bounds are to change in response to cropping (but have not yet done so).

Discussion

Efficient cropping is only performed when the receiver’s view’s contentMode is UIViewContentModeScaleAspectFill. By default, cropping is enabled. The crop alignment may be controlled via cropAlignmentFactor.

Declared In

ASImageNode.h

  cropRect

A value that controls how the receiver’s efficient cropping is aligned.

@property (nonatomic, readwrite, assign) CGRect cropRect

Discussion

This value defines a rectangle that is to be featured by the receiver. The rectangle is specified as a “unit rectangle,” using fractions of the source image’s width and height, e.g. CGRectMake(0.5, 0, 0.5, 1.0) will feature the full right half a photo. If the cropRect is empty, the content mode of the receiver will be used to determine its dimensions, and only the cropRect’s origin will be used for positioning. The default value of this property is CGRectMake(0.5, 0.5, 0.0, 0.0).

Declared In

ASImageNode.h

  imageModificationBlock

An optional block which can perform drawing operations on image during the display phase.

@property (nullable, nonatomic, readwrite, copy) asimagenode_modification_block_t imageModificationBlock

Discussion

Can be used to add image effects (such as rounding, adding borders, or other pattern overlays) without extraneous display calls.

Declared In

ASImageNode.h

– setNeedsDisplayWithCompletion:

Marks the receiver as needing display and performs a block after display has finished.

- (void)setNeedsDisplayWithCompletion:(nullable void ( ^ ) ( BOOL canceled ))displayCompletionBlock

Parameters

displayCompletionBlock

The block to be performed after display has finished. Its canceled property will be YES if display was prevented or canceled (via displaySuspended); NO otherwise.

Discussion

displayCompletionBlock will be performed on the main-thread. If displaySuspended is YES, displayCompletionBlock is will be performed immediately and YES will be passed for canceled.

Declared In

ASImageNode.h

  isDefaultFocusAppearance

A bool to track if the current appearance of the node is the default focus appearance. Exposed here so the category methods can set it.

@property (nonatomic, assign) BOOL isDefaultFocusAppearance

Declared In

ASImageNode.h