CALayerBuilder

Struct CALayerBuilder 

Source
pub struct CALayerBuilder { /* private fields */ }
Expand description

Builder for CALayer.

let layer = CALayerBuilder::new()
    .bounds(CGRect::new(CGPoint::ZERO, CGSize::new(100.0, 100.0)))
    .position(CGPoint::new(50.0, 50.0))
    .background_color(Color::DARK_GRAY)
    .corner_radius(8.0)
    .build();

Implementations§

Source§

impl CALayerBuilder

Source

pub fn new() -> Self

Creates a new builder with default values.

Source

pub fn bounds(self, bounds: CGRect) -> Self

Sets the bounds rectangle.

Source

pub fn position(self, position: CGPoint) -> Self

Sets the position in superlayer coordinates.

Source

pub fn background_color(self, color: impl Into<CFRetained<CGColor>>) -> Self

Sets the background color.

Accepts any type that implements Into<CFRetained<CGColor>>, including:

  • Color::RED, Color::rgb(1.0, 0.0, 0.0)
  • CFRetained<CGColor> directly
§Example
.background_color(Color::BLUE)
.background_color(Color::rgb(0.2, 0.2, 0.2))
.background_color(Color::WHITE.with_alpha(0.5))
Source

pub fn background_rgba( self, r: CGFloat, g: CGFloat, b: CGFloat, a: CGFloat, ) -> Self

Sets the background color from RGBA values (0.0–1.0).

Source

pub fn corner_radius(self, radius: CGFloat) -> Self

Sets the corner radius.

Source

pub fn hidden(self, hidden: bool) -> Self

Sets whether the layer is hidden.

Source

pub fn transform(self, transform: CATransform3D) -> Self

Sets the 3D transform.

Source

pub fn opacity(self, opacity: f32) -> Self

Sets the opacity (0.0–1.0).

Source

pub fn build(self) -> Retained<CALayer>

Builds and returns the configured CALayer.

Trait Implementations§

Source§

impl Default for CALayerBuilder

Source§

fn default() -> CALayerBuilder

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> AutoreleaseSafe for T
where T: ?Sized,