Inherits from NSView
Declared in CNBaseView.h

Tasks

View Creation

View Content

  •   icon

    An image that is shown centered of the view.

    property
  •   text

    A string with a message.

    property
  •   attributedText

    An attributed string with a message.

    property

View Behavior

Handling Subviews

Properties

attributedText

An attributed string with a message.

@property (strong, nonatomic) NSAttributedString *attributedText

Discussion

This string will be show below the icon in a distance of the value set by iconTextMargin.

Declared In

CNBaseView.h

backgroundColor

Property to set the backgroundcolor of the view.

@property (assign, nonatomic) NSColor *backgroundColor

Discussion

Due to the fact that the value of this property is passed through the receivers layer CNBaseView is switching [self setWantsLayer:YES]; to ON by default. You can use any NSColor instances and colors with pattern images too.

Declared In

CNBaseView.h

icon

An image that is shown centered of the view.

@property (strong, nonatomic) NSImage *icon

Declared In

CNBaseView.h

iconTextMargin

Float value to define the distance between icon and text message.

@property (assign, nonatomic) CGFloat iconTextMargin

Discussion

The distance is measured from the bottom icon edge (NSMinY(iconRect)) to the top text box edge (NSMaxY(textRect)).
The default value is 10.0f.

Declared In

CNBaseView.h

iconVerticalOffset

Float value to define a vertical offset for the icons view point.

@property (assign, nonatomic) CGFloat iconVerticalOffset

Discussion

The default value is 10.0f.

Declared In

CNBaseView.h

preventDrawingWithSubviews

Property with a boolean value that indicates whether CNBaseView should draw an icon and text if there are subviews present or not.

@property (assign) BOOL preventDrawingWithSubviews

Parameters

preventDrawingWithSubviews

YES (default value) will stop drawing the icon and text if there are subviews available. NO will always draw the icon and text.

Discussion

Normally you will add subviews to this view that acts as a root view. If CNBaseView is detecting just one subview it will prevent drawing the icon and text. This is the default behavior.
But sometimes you may would like to CNBaseView keep drawing its icon and text message even if there are subviews or not. In this case you have to set it to `NO'.

Declared In

CNBaseView.h

text

A string with a message.

@property (strong, nonatomic) NSString *text

Discussion

This string will be show below the icon in a distance of the value by iconTextMargin.

Declared In

CNBaseView.h

textBoxWidth

Float value to define the width of the text box rectangle.

@property (assign, nonatomic) CGFloat textBoxWidth

Discussion

The height of the text box rectangle is calculated automatically.
The default value is 350.0f.

Declared In

CNBaseView.h

Instance Methods

initWithIcon:attributedText:

Creates and return an CNBaseView instance that is displaying the given icon and the attributed text.

- (id)initWithIcon:(NSImage *)icon attributedText:(NSAttributedString *)attributedText

Parameters

icon

An NSImage object containing the icon.

text

An NSAttributedString object containing the text message with all the attributes you want.

Declared In

CNBaseView.h

initWithIcon:text:

Creates and return an CNBaseView instance that is displaying the given icon and text.

- (id)initWithIcon:(NSImage *)icon text:(NSString *)text

Parameters

icon

An NSImage object containing the icon.

text

An NSString object containing the text message.

Discussion

The text is displayed as an attributed string with the internal default text attributes:

NSFontAttributeName :               [NSFont fontWithName:@"HelveticaNeue-Medium" size:18.0f],
NSForegroundColorAttributeName :    [NSColor lightGrayColor],
NSShadowAttributeName :             white shadow color with a shadow offset (0, -1),
NSParagraphStyleAttributeName :     defaultParagraphStyle with alignment NSCenterTextAlignment,
NSKernAttributeName :               @0.95f

Declared In

CNBaseView.h

popChildViewWithAnimationEffect:duration:usingCompletionHandler:

Pops the child view and updates the display using a given animation duration

- (void)popChildViewWithAnimationEffect:(CNChildViewAnimationEffect)effect duration:(CGFloat)duration usingCompletionHandler:(void ( ^ ) ( void ))completionHandler

Discussion

Animation effects are the same as described in popChildViewWithAnimationEffect:usingCompletionHandler:

Declared In

CNBaseView.h

popChildViewWithAnimationEffect:usingCompletionHandler:

Pops the child view and updates the display.

- (void)popChildViewWithAnimationEffect:(CNChildViewAnimationEffect)effect usingCompletionHandler:(void ( ^ ) ( void ))completionHandler

Declared In

CNBaseView.h

pushChildView:withAnimationEffect:duration:usingCompletionHandler:

Pushs in another view as subview using the defined animation effect with a given animation duration.

- (void)pushChildView:(NSView *)childView withAnimationEffect:(CNChildViewAnimationEffect)effect duration:(CGFloat)duration usingCompletionHandler:(void ( ^ ) ( void ))completionHandler

Discussion

Animation effects are the same as described in pushChildView:withAnimationEffect:usingCompletionHandler:

Declared In

CNBaseView.h

pushChildView:withAnimationEffect:usingCompletionHandler:

Pushs in another view as subview using the defined animation effect.

- (void)pushChildView:(NSView *)childView withAnimationEffect:(CNChildViewAnimationEffect)effect usingCompletionHandler:(void ( ^ ) ( void ))completionHandler

Discussion

There are several animation effects available:

typedef enum {
    CNChildViewAnimationEffectNone = 0,
    CNChildViewAnimationEffectFade,
    CNChildViewAnimationEffectSlideTop,
    CNChildViewAnimationEffectSlideRight,
    CNChildViewAnimationEffectSlideBottom,
    CNChildViewAnimationEffectSlideLeft
} CNChildViewAnimationEffect;

CNChildViewAnimationEffectNone
The child view will be shown immediatly without an animation effect. It abolishes the setting of preventDrawingWithSubviews, the icon and text are not drawn.

CNChildViewAnimationEffectFade
The child view will fade in.

CNChildViewAnimationEffectSlideTop
The child view will silde in from the top edge downwards.

CNChildViewAnimationEffectSlideRight
The child view will silde in from the right edge to the left.

CNChildViewAnimationEffectSlideBottom
The child view will silde in from the bottom edge upwards.

CNChildViewAnimationEffectSlideLeft
The child view will silde in from left edge to the right.

After the animation is done the completionHandler is executed.

Note: If you decide to use one of these effects and the value of preventDrawingWithSubviews is set to NO then you have to ensure that your pushing child view has an opaque background. Otherwise the drawn icon and text message will be shown through.

Declared In

CNBaseView.h