pub struct AVCaptureVideoPreviewLayer { /* private fields */ }AVCaptureVideoPreviewLayer and crate feature objc2-quartz-core and non-watchOS only.Expand description
A CoreAnimation layer subclass for previewing the visual output of an AVCaptureSession.
An AVCaptureVideoPreviewLayer instance is a subclass of CALayer and is therefore suitable for insertion in a layer hierarchy as part of a graphical interface. One creates an AVCaptureVideoPreviewLayer instance with the capture session to be previewed, using +layerWithSession: or -initWithSession:. Using the “ videoGravity“ property, one can influence how content is viewed relative to the layer bounds. On some hardware configurations, the orientation of the layer can be manipulated using @“orientation” and @“mirrored”.
See also Apple’s documentation
Implementations§
Source§impl AVCaptureVideoPreviewLayer
impl AVCaptureVideoPreviewLayer
Sourcepub unsafe fn layerWithSession(session: &AVCaptureSession) -> Retained<Self>
Available on crate feature AVCaptureSession only.
pub unsafe fn layerWithSession(session: &AVCaptureSession) -> Retained<Self>
AVCaptureSession only.Creates an AVCaptureVideoPreviewLayer for previewing the visual output of the specified AVCaptureSession.
Parameter session: The AVCaptureSession instance to be previewed.
Returns: A newly initialized AVCaptureVideoPreviewLayer instance.
Sourcepub unsafe fn initWithSession(
this: Allocated<Self>,
session: &AVCaptureSession,
) -> Retained<Self>
Available on crate feature AVCaptureSession only.
pub unsafe fn initWithSession( this: Allocated<Self>, session: &AVCaptureSession, ) -> Retained<Self>
AVCaptureSession only.Creates an AVCaptureVideoPreviewLayer for previewing the visual output of the specified AVCaptureSession.
Parameter session: The AVCaptureSession instance to be previewed.
Returns: A newly initialized AVCaptureVideoPreviewLayer instance.
Sourcepub unsafe fn layerWithSessionWithNoConnection(
session: &AVCaptureSession,
) -> Retained<Self>
Available on crate feature AVCaptureSession only.
pub unsafe fn layerWithSessionWithNoConnection( session: &AVCaptureSession, ) -> Retained<Self>
AVCaptureSession only.Creates an AVCaptureVideoPreviewLayer for previewing the visual output of the specified AVCaptureSession, but creates no connections to any of the session’s eligible video inputs. Only use this initializer if you intend to manually form a connection between a desired AVCaptureInputPort and the receiver using AVCaptureSession’s -addConnection: method.
Parameter session: The AVCaptureSession instance to be previewed.
Returns: A newly initialized AVCaptureVideoPreviewLayer instance.
Sourcepub unsafe fn initWithSessionWithNoConnection(
this: Allocated<Self>,
session: &AVCaptureSession,
) -> Retained<Self>
Available on crate feature AVCaptureSession only.
pub unsafe fn initWithSessionWithNoConnection( this: Allocated<Self>, session: &AVCaptureSession, ) -> Retained<Self>
AVCaptureSession only.Creates an AVCaptureVideoPreviewLayer for previewing the visual output of the specified AVCaptureSession, but creates no connections to any of the session’s eligible video inputs. Only use this initializer if you intend to manually form a connection between a desired AVCaptureInputPort and the receiver using AVCaptureSession’s -addConnection: method.
Parameter session: The AVCaptureSession instance to be previewed.
Returns: A newly initialized AVCaptureVideoPreviewLayer instance.
Sourcepub unsafe fn session(&self) -> Option<Retained<AVCaptureSession>>
Available on crate feature AVCaptureSession only.
pub unsafe fn session(&self) -> Option<Retained<AVCaptureSession>>
AVCaptureSession only.The AVCaptureSession instance being previewed by the receiver.
The session is retained by the preview layer.
Sourcepub unsafe fn setSession(&self, session: Option<&AVCaptureSession>)
Available on crate feature AVCaptureSession only.
pub unsafe fn setSession(&self, session: Option<&AVCaptureSession>)
AVCaptureSession only.Setter for session.
Sourcepub unsafe fn setSessionWithNoConnection(&self, session: &AVCaptureSession)
Available on crate feature AVCaptureSession only.
pub unsafe fn setSessionWithNoConnection(&self, session: &AVCaptureSession)
AVCaptureSession only.method setSessionWithNoConnection:
Attaches the receiver to a given session without implicitly forming a connection to the first eligible video AVCaptureInputPort. Only use this setter if you intend to manually form a connection between a desired AVCaptureInputPort and the receiver using AVCaptureSession’s -addConnection: method.
The session is retained by the preview layer.
Sourcepub unsafe fn connection(&self) -> Option<Retained<AVCaptureConnection>>
Available on crate feature AVCaptureSession only.
pub unsafe fn connection(&self) -> Option<Retained<AVCaptureConnection>>
AVCaptureSession only.The AVCaptureConnection instance describing the AVCaptureInputPort to which the receiver is connected.
When calling initWithSession: or setSession: with a valid AVCaptureSession instance, a connection is formed to the first eligible video AVCaptureInput. If the receiver is detached from a session, the connection property becomes nil.
Sourcepub unsafe fn videoGravity(&self) -> Retained<AVLayerVideoGravity>
Available on crate feature AVAnimation only.
pub unsafe fn videoGravity(&self) -> Retained<AVLayerVideoGravity>
AVAnimation only.A string defining how the video is displayed within an AVCaptureVideoPreviewLayer bounds rect.
Options are AVLayerVideoGravityResize, AVLayerVideoGravityResizeAspect and AVLayerVideoGravityResizeAspectFill. AVLayerVideoGravityResizeAspect is default. See <AVFoundation /AVAnimation.h> for a description of these options.
Sourcepub unsafe fn setVideoGravity(&self, video_gravity: &AVLayerVideoGravity)
Available on crate feature AVAnimation only.
pub unsafe fn setVideoGravity(&self, video_gravity: &AVLayerVideoGravity)
AVAnimation only.Setter for videoGravity.
This is copied when set.
Sourcepub unsafe fn isPreviewing(&self) -> bool
pub unsafe fn isPreviewing(&self) -> bool
A BOOL value indicating whether the receiver is currently rendering video frames from its source.
An AVCaptureVideoPreviewLayer begins previewing when -[AVCaptureSession startRunning] is called. When associated with an AVCaptureMultiCamSession, all video preview layers are guaranteed to be previewing by the time the blocking call to -startRunning or -commitConfiguration returns. While a session is running, you may enable or disable a video preview layer’s connection to re-start or stop the flow of video to the layer. Once you’ve set enabled to YES, you can observe this property changing from NO to YES and synchronize any UI to take place precisely when the video resumes rendering to the video preview layer.
Sourcepub unsafe fn captureDevicePointOfInterestForPoint(
&self,
point_in_layer: CGPoint,
) -> CGPoint
Available on crate feature objc2-core-foundation only.
pub unsafe fn captureDevicePointOfInterestForPoint( &self, point_in_layer: CGPoint, ) -> CGPoint
objc2-core-foundation only.Converts a point in layer coordinates to a point of interest in the coordinate space of the capture device providing input to the layer.
Parameter pointInLayer: A CGPoint in layer coordinates.
Returns: A CGPoint in the coordinate space of the capture device providing input to the layer.
AVCaptureDevice pointOfInterest is expressed as a CGPoint where {0,0} represents the top left of the picture area, and {1,1} represents the bottom right on an unrotated picture. This convenience method converts a point in the coordinate space of the receiver to a point of interest in the coordinate space of the AVCaptureDevice providing input to the receiver. The conversion takes frameSize and videoGravity into consideration.
Sourcepub unsafe fn pointForCaptureDevicePointOfInterest(
&self,
capture_device_point_of_interest: CGPoint,
) -> CGPoint
Available on crate feature objc2-core-foundation only.
pub unsafe fn pointForCaptureDevicePointOfInterest( &self, capture_device_point_of_interest: CGPoint, ) -> CGPoint
objc2-core-foundation only.Converts a point of interest in the coordinate space of the capture device providing input to the layer to a point in layer coordinates.
Parameter captureDevicePointOfInterest: A CGPoint in the coordinate space of the capture device providing input to the layer.
Returns: A CGPoint in layer coordinates.
AVCaptureDevice pointOfInterest is expressed as a CGPoint where {0,0} represents the top left of the picture area, and {1,1} represents the bottom right on an unrotated picture. This convenience method converts a point in the coordinate space of the AVCaptureDevice providing input to the coordinate space of the receiver. The conversion takes frame size and videoGravity into consideration.
Sourcepub unsafe fn metadataOutputRectOfInterestForRect(
&self,
rect_in_layer_coordinates: CGRect,
) -> CGRect
Available on crate feature objc2-core-foundation only.
pub unsafe fn metadataOutputRectOfInterestForRect( &self, rect_in_layer_coordinates: CGRect, ) -> CGRect
objc2-core-foundation only.Converts a rectangle in layer coordinates to a rectangle of interest in the coordinate space of an AVCaptureMetadataOutput whose capture device is providing input to the layer.
Parameter rectInLayerCoordinates: A CGRect in layer coordinates.
Returns: A CGRect in the coordinate space of the metadata output whose capture device is providing input to the layer.
AVCaptureMetadataOutput rectOfInterest is expressed as a CGRect where {0,0} represents the top left of the picture area, and {1,1} represents the bottom right on an unrotated picture. This convenience method converts a rectangle in the coordinate space of the receiver to a rectangle of interest in the coordinate space of an AVCaptureMetadataOutput whose AVCaptureDevice is providing input to the receiver. The conversion takes frame size and videoGravity into consideration.
Sourcepub unsafe fn rectForMetadataOutputRectOfInterest(
&self,
rect_in_metadata_output_coordinates: CGRect,
) -> CGRect
Available on crate feature objc2-core-foundation only.
pub unsafe fn rectForMetadataOutputRectOfInterest( &self, rect_in_metadata_output_coordinates: CGRect, ) -> CGRect
objc2-core-foundation only.Converts a rectangle of interest in the coordinate space of an AVCaptureMetadataOutput whose capture device is providing input to the layer to a rectangle in layer coordinates.
Parameter rectInMetadataOutputCoordinates: A CGRect in the coordinate space of the metadata output whose capture device is providing input to the layer.
Returns: A CGRect in layer coordinates.
AVCaptureMetadataOutput rectOfInterest is expressed as a CGRect where {0,0} represents the top left of the picture area, and {1,1} represents the bottom right on an unrotated picture. This convenience method converts a rectangle in the coordinate space of an AVCaptureMetadataOutput whose AVCaptureDevice is providing input to the coordinate space of the receiver. The conversion takes frame size and videoGravity into consideration.
Sourcepub unsafe fn transformedMetadataObjectForMetadataObject(
&self,
metadata_object: &AVMetadataObject,
) -> Option<Retained<AVMetadataObject>>
Available on crate feature AVMetadataObject only.
pub unsafe fn transformedMetadataObjectForMetadataObject( &self, metadata_object: &AVMetadataObject, ) -> Option<Retained<AVMetadataObject>>
AVMetadataObject only.Converts an AVMetadataObject’s visual properties to layer coordinates.
Parameter metadataObject: An AVMetadataObject originating from the same AVCaptureInput as the preview layer.
Returns: An AVMetadataObject whose properties are in layer coordinates.
AVMetadataObject bounds may be expressed as a rect where {0,0} represents the top left of the picture area, and {1,1} represents the bottom right on an unrotated picture. Face metadata objects likewise express yaw and roll angles with respect to an unrotated picture. -transformedMetadataObjectForMetadataObject: converts the visual properties in the coordinate space of the supplied AVMetadataObject to the coordinate space of the receiver. The conversion takes orientation, mirroring, layer bounds and videoGravity into consideration. If the provided metadata object originates from an input source other than the preview layer’s, nil will be returned.
Sourcepub unsafe fn isOrientationSupported(&self) -> bool
👎Deprecated: Use AVCaptureConnection’s isVideoOrientationSupported instead.
pub unsafe fn isOrientationSupported(&self) -> bool
Specifies whether or not the preview layer supports orientation.
Changes in orientation are not supported on all hardware configurations. An application should check the value of “ orientationSupported“ before attempting to manipulate the orientation of the receiver. This property is deprecated. Use AVCaptureConnection’s -isVideoOrientationSupported instead.
Sourcepub unsafe fn orientation(&self) -> AVCaptureVideoOrientation
👎Deprecated: Use AVCaptureConnection’s videoOrientation instead.Available on crate feature AVCaptureSession only.
pub unsafe fn orientation(&self) -> AVCaptureVideoOrientation
AVCaptureSession only.Specifies the orientation of the preview layer.
AVCaptureVideoOrientation and its constants are defined in AVCaptureSession.h. The value of “ orientationSupported“ must be YES in order to set @“orientation”. An exception will be raised if this requirement is ignored. This property is deprecated. Use AVCaptureConnection’s -videoOrientation instead.
Sourcepub unsafe fn setOrientation(&self, orientation: AVCaptureVideoOrientation)
👎Deprecated: Use AVCaptureConnection’s videoOrientation instead.Available on crate feature AVCaptureSession only.
pub unsafe fn setOrientation(&self, orientation: AVCaptureVideoOrientation)
AVCaptureSession only.Setter for orientation.
Sourcepub unsafe fn isMirroringSupported(&self) -> bool
👎Deprecated: Use AVCaptureConnection’s isVideoMirroringSupported instead.
pub unsafe fn isMirroringSupported(&self) -> bool
Specifies whether or not the preview layer supports mirroring.
Mirroring is not supported on all hardware configurations. An application should check the value of “ mirroringSupported“ before attempting to manipulate mirroring on the receiver. This property is deprecated. Use AVCaptureConnection’s -isVideoMirroringSupported instead.
Sourcepub unsafe fn automaticallyAdjustsMirroring(&self) -> bool
👎Deprecated: Use AVCaptureConnection’s automaticallyAdjustsVideoMirroring instead.
pub unsafe fn automaticallyAdjustsMirroring(&self) -> bool
Specifies whether or not the value of “ mirrored“ can change based on configuration of the session.
For some session configurations, preview will be mirrored by default. When the value of this property is YES, the value of “ mirrored“ may change depending on the configuration of the session, for example after switching to a different AVCaptureDeviceInput. The default value is YES. This property is deprecated. Use AVCaptureConnection’s -automaticallyAdjustsVideoMirroring instead.
Sourcepub unsafe fn setAutomaticallyAdjustsMirroring(
&self,
automatically_adjusts_mirroring: bool,
)
👎Deprecated: Use AVCaptureConnection’s automaticallyAdjustsVideoMirroring instead.
pub unsafe fn setAutomaticallyAdjustsMirroring( &self, automatically_adjusts_mirroring: bool, )
Setter for automaticallyAdjustsMirroring.
Sourcepub unsafe fn isMirrored(&self) -> bool
👎Deprecated: Use AVCaptureConnection’s videoMirrored instead.
pub unsafe fn isMirrored(&self) -> bool
Specifies whether or not the preview is flipped over a vertical axis.
For most applications, it is unnecessary to manipulate preview mirroring manually if “ automaticallyAdjustsMirroring“ is set to YES. The value of @“automaticallyAdjustsMirroring” must be NO in order to set @“mirrored”. The value of @“mirroringSupported” must be YES in order to set @“mirrored”. An exception will be raised if the value of @“mirrored” is mutated without respecting these requirements. This property is deprecated. Use AVCaptureConnection’s -videoMirrored instead.
Sourcepub unsafe fn setMirrored(&self, mirrored: bool)
👎Deprecated: Use AVCaptureConnection’s videoMirrored instead.
pub unsafe fn setMirrored(&self, mirrored: bool)
Setter for isMirrored.
Sourcepub unsafe fn isDeferredStartSupported(&self) -> bool
pub unsafe fn isDeferredStartSupported(&self) -> bool
A BOOL value that indicates whether the preview layer supports deferred start.
You can only set the deferredStartEnabled property to true if the preview layer supports deferred start.
Sourcepub unsafe fn isDeferredStartEnabled(&self) -> bool
pub unsafe fn isDeferredStartEnabled(&self) -> bool
A BOOL value that indicates whether to defer starting this preview layer.
When this value is true, the session does not prepare the output’s resources until some time after AVCaptureSession/startRunning returns. You can start the visual parts of your user interface (e.g. preview) prior to other parts (e.g. photo/movie capture, metadata output, etc..) to improve startup performance. Set this value to false if your app needs video preview immediately for startup, and true if it does not.
By default, this value is false for AVCaptureVideoPreviewLayer objects, since this object is used to display preview. For best session start performance, set deferredStartEnabled to false for preview layers. If your app contains multiple preview layers, you may want to display the main preview layer as soon as possible and allow the remaining layers to display subsequently. In this case, set deferredStartEnabled to true for the remaining layers.
- Note: Setting this property to the same value for all outputs, including
AVCaptureVideoPreviewLayerandAVCaptureOutput, is equivalent to not using deferred start.
If deferredStartSupported is false, setting this property value to true results in the session throwing an NSInvalidArgumentException.
- Note: Set this value before calling
AVCaptureSession/commitConfigurationas it requires a lengthy reconfiguration of the capture render pipeline.
Sourcepub unsafe fn setDeferredStartEnabled(&self, deferred_start_enabled: bool)
pub unsafe fn setDeferredStartEnabled(&self, deferred_start_enabled: bool)
Setter for isDeferredStartEnabled.
Source§impl AVCaptureVideoPreviewLayer
Methods declared on superclass CALayer.
impl AVCaptureVideoPreviewLayer
Methods declared on superclass CALayer.
Methods from Deref<Target = CALayer>§
pub unsafe fn presentationLayer(&self) -> Option<Retained<CALayer>>
pub unsafe fn modelLayer(&self) -> Retained<CALayer>
pub fn shouldArchiveValueForKey(&self, key: &NSString) -> bool
pub fn isHidden(&self) -> bool
pub fn isDoubleSided(&self) -> bool
Sourcepub fn setDoubleSided(&self, double_sided: bool)
pub fn setDoubleSided(&self, double_sided: bool)
Setter for isDoubleSided.
pub fn isGeometryFlipped(&self) -> bool
Sourcepub fn setGeometryFlipped(&self, geometry_flipped: bool)
pub fn setGeometryFlipped(&self, geometry_flipped: bool)
Setter for isGeometryFlipped.
pub fn contentsAreFlipped(&self) -> bool
pub fn superlayer(&self) -> Option<Retained<CALayer>>
pub fn removeFromSuperlayer(&self)
pub unsafe fn sublayers(&self) -> Option<Retained<NSArray<CALayer>>>
Sourcepub unsafe fn setSublayers(&self, sublayers: Option<&NSArray<CALayer>>)
pub unsafe fn setSublayers(&self, sublayers: Option<&NSArray<CALayer>>)
pub fn addSublayer(&self, layer: &CALayer)
pub fn insertSublayer_atIndex(&self, layer: &CALayer, idx: u32)
pub fn insertSublayer_below(&self, layer: &CALayer, sibling: Option<&CALayer>)
pub fn insertSublayer_above(&self, layer: &CALayer, sibling: Option<&CALayer>)
pub unsafe fn replaceSublayer_with( &self, old_layer: &CALayer, new_layer: &CALayer, )
pub fn mask(&self) -> Option<Retained<CALayer>>
pub fn masksToBounds(&self) -> bool
Sourcepub fn setMasksToBounds(&self, masks_to_bounds: bool)
pub fn setMasksToBounds(&self, masks_to_bounds: bool)
Setter for masksToBounds.
Sourcepub unsafe fn contents(&self) -> Option<Retained<AnyObject>>
pub unsafe fn contents(&self) -> Option<Retained<AnyObject>>
Layer content properties and methods. *
Sourcepub unsafe fn setContents(&self, contents: Option<&AnyObject>)
pub unsafe fn setContents(&self, contents: Option<&AnyObject>)
pub fn contentsGravity(&self) -> Retained<NSString>
Sourcepub fn setContentsGravity(&self, contents_gravity: &NSString)
pub fn setContentsGravity(&self, contents_gravity: &NSString)
Setter for contentsGravity.
This is copied when set.
pub fn contentsFormat(&self) -> Retained<NSString>
Sourcepub fn setContentsFormat(&self, contents_format: &NSString)
pub fn setContentsFormat(&self, contents_format: &NSString)
Setter for contentsFormat.
This is copied when set.
pub fn wantsExtendedDynamicRangeContent(&self) -> bool
Sourcepub fn setWantsExtendedDynamicRangeContent(
&self,
wants_extended_dynamic_range_content: bool,
)
👎Deprecated: Use preferredDynamicRange instead
pub fn setWantsExtendedDynamicRangeContent( &self, wants_extended_dynamic_range_content: bool, )
Setter for wantsExtendedDynamicRangeContent.
pub fn toneMapMode(&self) -> Retained<NSString>
Sourcepub fn setToneMapMode(&self, tone_map_mode: &NSString)
pub fn setToneMapMode(&self, tone_map_mode: &NSString)
Setter for toneMapMode.
This is copied when set.
pub fn preferredDynamicRange(&self) -> Retained<NSString>
Sourcepub fn setPreferredDynamicRange(&self, preferred_dynamic_range: &NSString)
pub fn setPreferredDynamicRange(&self, preferred_dynamic_range: &NSString)
Setter for preferredDynamicRange.
This is copied when set.
pub fn wantsDynamicContentScaling(&self) -> bool
Sourcepub fn setWantsDynamicContentScaling(&self, wants_dynamic_content_scaling: bool)
pub fn setWantsDynamicContentScaling(&self, wants_dynamic_content_scaling: bool)
Setter for wantsDynamicContentScaling.
pub fn minificationFilter(&self) -> Retained<NSString>
Sourcepub fn setMinificationFilter(&self, minification_filter: &NSString)
pub fn setMinificationFilter(&self, minification_filter: &NSString)
Setter for minificationFilter.
This is copied when set.
pub fn magnificationFilter(&self) -> Retained<NSString>
Sourcepub fn setMagnificationFilter(&self, magnification_filter: &NSString)
pub fn setMagnificationFilter(&self, magnification_filter: &NSString)
Setter for magnificationFilter.
This is copied when set.
pub fn minificationFilterBias(&self) -> f32
Sourcepub fn setMinificationFilterBias(&self, minification_filter_bias: f32)
pub fn setMinificationFilterBias(&self, minification_filter_bias: f32)
Setter for minificationFilterBias.
pub fn isOpaque(&self) -> bool
pub fn display(&self)
pub fn setNeedsDisplay(&self)
pub fn needsDisplay(&self) -> bool
pub fn displayIfNeeded(&self)
pub fn needsDisplayOnBoundsChange(&self) -> bool
Sourcepub fn setNeedsDisplayOnBoundsChange(
&self,
needs_display_on_bounds_change: bool,
)
pub fn setNeedsDisplayOnBoundsChange( &self, needs_display_on_bounds_change: bool, )
Setter for needsDisplayOnBoundsChange.
pub fn drawsAsynchronously(&self) -> bool
Sourcepub fn setDrawsAsynchronously(&self, draws_asynchronously: bool)
pub fn setDrawsAsynchronously(&self, draws_asynchronously: bool)
Setter for drawsAsynchronously.
pub fn edgeAntialiasingMask(&self) -> CAEdgeAntialiasingMask
Sourcepub fn setEdgeAntialiasingMask(
&self,
edge_antialiasing_mask: CAEdgeAntialiasingMask,
)
pub fn setEdgeAntialiasingMask( &self, edge_antialiasing_mask: CAEdgeAntialiasingMask, )
Setter for edgeAntialiasingMask.
pub fn allowsEdgeAntialiasing(&self) -> bool
Sourcepub fn setAllowsEdgeAntialiasing(&self, allows_edge_antialiasing: bool)
pub fn setAllowsEdgeAntialiasing(&self, allows_edge_antialiasing: bool)
Setter for allowsEdgeAntialiasing.
pub fn maskedCorners(&self) -> CACornerMask
Sourcepub fn setMaskedCorners(&self, masked_corners: CACornerMask)
pub fn setMaskedCorners(&self, masked_corners: CACornerMask)
Setter for maskedCorners.
pub fn cornerCurve(&self) -> Retained<NSString>
Sourcepub fn setCornerCurve(&self, corner_curve: &NSString)
pub fn setCornerCurve(&self, corner_curve: &NSString)
Setter for cornerCurve.
This is copied when set.
pub fn opacity(&self) -> f32
Sourcepub fn setOpacity(&self, opacity: f32)
pub fn setOpacity(&self, opacity: f32)
Setter for opacity.
pub fn allowsGroupOpacity(&self) -> bool
Sourcepub fn setAllowsGroupOpacity(&self, allows_group_opacity: bool)
pub fn setAllowsGroupOpacity(&self, allows_group_opacity: bool)
Setter for allowsGroupOpacity.
pub fn compositingFilter(&self) -> Option<Retained<AnyObject>>
Sourcepub unsafe fn setCompositingFilter(
&self,
compositing_filter: Option<&AnyObject>,
)
pub unsafe fn setCompositingFilter( &self, compositing_filter: Option<&AnyObject>, )
pub fn filters(&self) -> Option<Retained<NSArray>>
Sourcepub unsafe fn setFilters(&self, filters: Option<&NSArray>)
pub unsafe fn setFilters(&self, filters: Option<&NSArray>)
pub fn backgroundFilters(&self) -> Option<Retained<NSArray>>
Sourcepub unsafe fn setBackgroundFilters(&self, background_filters: Option<&NSArray>)
pub unsafe fn setBackgroundFilters(&self, background_filters: Option<&NSArray>)
Setter for backgroundFilters.
This is copied when set.
§Safety
background_filters generic should be of the correct type.
pub fn shouldRasterize(&self) -> bool
Sourcepub fn setShouldRasterize(&self, should_rasterize: bool)
pub fn setShouldRasterize(&self, should_rasterize: bool)
Setter for shouldRasterize.
pub fn shadowOpacity(&self) -> f32
Sourcepub fn setShadowOpacity(&self, shadow_opacity: f32)
pub fn setShadowOpacity(&self, shadow_opacity: f32)
Setter for shadowOpacity.
Sourcepub fn autoresizingMask(&self) -> CAAutoresizingMask
pub fn autoresizingMask(&self) -> CAAutoresizingMask
Layout methods. *
Sourcepub fn setAutoresizingMask(&self, autoresizing_mask: CAAutoresizingMask)
pub fn setAutoresizingMask(&self, autoresizing_mask: CAAutoresizingMask)
Setter for autoresizingMask.
pub fn layoutManager( &self, ) -> Option<Retained<ProtocolObject<dyn CALayoutManager>>>
Sourcepub fn setLayoutManager(
&self,
layout_manager: Option<&ProtocolObject<dyn CALayoutManager>>,
)
pub fn setLayoutManager( &self, layout_manager: Option<&ProtocolObject<dyn CALayoutManager>>, )
Setter for layoutManager.
pub fn setNeedsLayout(&self)
pub fn needsLayout(&self) -> bool
pub fn layoutIfNeeded(&self)
pub fn layoutSublayers(&self)
pub fn actionForKey( &self, event: &NSString, ) -> Option<Retained<ProtocolObject<dyn CAAction>>>
pub fn actions( &self, ) -> Option<Retained<NSDictionary<NSString, ProtocolObject<dyn CAAction>>>>
Sourcepub fn setActions(
&self,
actions: Option<&NSDictionary<NSString, ProtocolObject<dyn CAAction>>>,
)
pub fn setActions( &self, actions: Option<&NSDictionary<NSString, ProtocolObject<dyn CAAction>>>, )
pub fn removeAllAnimations(&self)
pub fn removeAnimationForKey(&self, key: &NSString)
pub fn animationKeys(&self) -> Option<Retained<NSArray<NSString>>>
pub fn delegate(&self) -> Option<Retained<ProtocolObject<dyn CALayerDelegate>>>
Sourcepub fn setDelegate(
&self,
delegate: Option<&ProtocolObject<dyn CALayerDelegate>>,
)
pub fn setDelegate( &self, delegate: Option<&ProtocolObject<dyn CALayerDelegate>>, )
Setter for delegate.
This is a weak property.
pub fn style(&self) -> Option<Retained<NSDictionary>>
Methods from Deref<Target = NSObject>§
Sourcepub fn doesNotRecognizeSelector(&self, sel: Sel) -> !
pub fn doesNotRecognizeSelector(&self, sel: Sel) -> !
Handle messages the object doesn’t recognize.
See Apple’s documentation for details.
Methods from Deref<Target = AnyObject>§
Sourcepub fn class(&self) -> &'static AnyClass
pub fn class(&self) -> &'static AnyClass
Dynamically find the class of this object.
§Panics
May panic if the object is invalid (which may be the case for objects
returned from unavailable init/new methods).
§Example
Check that an instance of NSObject has the precise class NSObject.
use objc2::ClassType;
use objc2::runtime::NSObject;
let obj = NSObject::new();
assert_eq!(obj.class(), NSObject::class());Sourcepub unsafe fn get_ivar<T>(&self, name: &str) -> &Twhere
T: Encode,
👎Deprecated: this is difficult to use correctly, use Ivar::load instead.
pub unsafe fn get_ivar<T>(&self, name: &str) -> &Twhere
T: Encode,
Ivar::load instead.Use Ivar::load instead.
§Safety
The object must have an instance variable with the given name, and it
must be of type T.
See Ivar::load_ptr for details surrounding this.
Sourcepub fn downcast_ref<T>(&self) -> Option<&T>where
T: DowncastTarget,
pub fn downcast_ref<T>(&self) -> Option<&T>where
T: DowncastTarget,
Attempt to downcast the object to a class of type T.
This is the reference-variant. Use Retained::downcast if you want
to convert a retained object to another type.
§Mutable classes
Some classes have immutable and mutable variants, such as NSString
and NSMutableString.
When some Objective-C API signature says it gives you an immutable class, it generally expects you to not mutate that, even though it may technically be mutable “under the hood”.
So using this method to convert a NSString to a NSMutableString,
while not unsound, is generally frowned upon unless you created the
string yourself, or the API explicitly documents the string to be
mutable.
See Apple’s documentation on mutability and on
isKindOfClass: for more details.
§Generic classes
Objective-C generics are called “lightweight generics”, and that’s because they aren’t exposed in the runtime. This makes it impossible to safely downcast to generic collections, so this is disallowed by this method.
You can, however, safely downcast to generic collections where all the
type-parameters are AnyObject.
§Panics
This works internally by calling isKindOfClass:. That means that the
object must have the instance method of that name, and an exception
will be thrown (if CoreFoundation is linked) or the process will abort
if that is not the case. In the vast majority of cases, you don’t need
to worry about this, since both root objects NSObject and
NSProxy implement this method.
§Examples
Cast an NSString back and forth from NSObject.
use objc2::rc::Retained;
use objc2_foundation::{NSObject, NSString};
let obj: Retained<NSObject> = NSString::new().into_super();
let string = obj.downcast_ref::<NSString>().unwrap();
// Or with `downcast`, if we do not need the object afterwards
let string = obj.downcast::<NSString>().unwrap();Try (and fail) to cast an NSObject to an NSString.
use objc2_foundation::{NSObject, NSString};
let obj = NSObject::new();
assert!(obj.downcast_ref::<NSString>().is_none());Try to cast to an array of strings.
use objc2_foundation::{NSArray, NSObject, NSString};
let arr = NSArray::from_retained_slice(&[NSObject::new()]);
// This is invalid and doesn't type check.
let arr = arr.downcast_ref::<NSArray<NSString>>();This fails to compile, since it would require enumerating over the array to ensure that each element is of the desired type, which is a performance pitfall.
Downcast when processing each element instead.
use objc2_foundation::{NSArray, NSObject, NSString};
let arr = NSArray::from_retained_slice(&[NSObject::new()]);
for elem in arr {
if let Some(data) = elem.downcast_ref::<NSString>() {
// handle `data`
}
}Trait Implementations§
Source§impl AsRef<AnyObject> for AVCaptureVideoPreviewLayer
impl AsRef<AnyObject> for AVCaptureVideoPreviewLayer
Source§impl AsRef<CALayer> for AVCaptureVideoPreviewLayer
impl AsRef<CALayer> for AVCaptureVideoPreviewLayer
Source§impl AsRef<NSObject> for AVCaptureVideoPreviewLayer
impl AsRef<NSObject> for AVCaptureVideoPreviewLayer
Source§impl Borrow<AnyObject> for AVCaptureVideoPreviewLayer
impl Borrow<AnyObject> for AVCaptureVideoPreviewLayer
Source§impl Borrow<CALayer> for AVCaptureVideoPreviewLayer
impl Borrow<CALayer> for AVCaptureVideoPreviewLayer
Source§impl Borrow<NSObject> for AVCaptureVideoPreviewLayer
impl Borrow<NSObject> for AVCaptureVideoPreviewLayer
Source§impl CAMediaTiming for AVCaptureVideoPreviewLayer
impl CAMediaTiming for AVCaptureVideoPreviewLayer
fn speed(&self) -> f32
fn repeatCount(&self) -> f32
Source§fn setRepeatCount(&self, repeat_count: f32)
fn setRepeatCount(&self, repeat_count: f32)
repeatCount.fn autoreverses(&self) -> bool
Source§fn setAutoreverses(&self, autoreverses: bool)
fn setAutoreverses(&self, autoreverses: bool)
autoreverses.fn fillMode(&self) -> Retained<NSString>
Source§impl ClassType for AVCaptureVideoPreviewLayer
impl ClassType for AVCaptureVideoPreviewLayer
Source§const NAME: &'static str = "AVCaptureVideoPreviewLayer"
const NAME: &'static str = "AVCaptureVideoPreviewLayer"
Source§type ThreadKind = <<AVCaptureVideoPreviewLayer as ClassType>::Super as ClassType>::ThreadKind
type ThreadKind = <<AVCaptureVideoPreviewLayer as ClassType>::Super as ClassType>::ThreadKind
Source§impl Debug for AVCaptureVideoPreviewLayer
impl Debug for AVCaptureVideoPreviewLayer
Source§impl Deref for AVCaptureVideoPreviewLayer
impl Deref for AVCaptureVideoPreviewLayer
Source§impl Hash for AVCaptureVideoPreviewLayer
impl Hash for AVCaptureVideoPreviewLayer
Source§impl Message for AVCaptureVideoPreviewLayer
impl Message for AVCaptureVideoPreviewLayer
Source§impl NSObjectProtocol for AVCaptureVideoPreviewLayer
impl NSObjectProtocol for AVCaptureVideoPreviewLayer
Source§fn isEqual(&self, other: Option<&AnyObject>) -> bool
fn isEqual(&self, other: Option<&AnyObject>) -> bool
Source§fn hash(&self) -> usize
fn hash(&self) -> usize
Source§fn isKindOfClass(&self, cls: &AnyClass) -> bool
fn isKindOfClass(&self, cls: &AnyClass) -> bool
Source§fn is_kind_of<T>(&self) -> bool
fn is_kind_of<T>(&self) -> bool
isKindOfClass directly, or cast your objects with AnyObject::downcast_ref