CNBaseView Class Reference
| Inherits from | NSView |
| Declared in | CNBaseView.h |
Tasks
View Creation
-
– initWithIcon:text:Creates and return an
CNBaseViewinstance that is displaying the given icon and text. -
– initWithIcon:attributedText:Creates and return an
CNBaseViewinstance that is displaying the given icon and the attributed text.
View Content
-
iconAn image that is shown centered of the view.
property -
textA string with a message.
property -
attributedTextAn attributed string with a message.
property
View Behavior
-
textBoxWidthFloat value to define the width of the text box rectangle.
property -
iconVerticalOffsetFloat value to define a vertical offset for the icons view point.
property -
iconTextMarginFloat value to define the distance between icon and text message.
property -
preventDrawingWithSubviewsProperty with a boolean value that indicates whether
propertyCNBaseViewshould draw an icon and text if there are subviews present or not. -
backgroundColorProperty to set the backgroundcolor of the view.
property
Handling Subviews
-
– pushChildView:withAnimationEffect:usingCompletionHandler:Pushs in another view as subview using the defined animation effect.
-
– pushChildView:withAnimationEffect:duration:usingCompletionHandler:Pushs in another view as subview using the defined animation effect with a given animation duration.
-
– popChildViewWithAnimationEffect:usingCompletionHandler:Pops the child view and updates the display.
-
– popChildViewWithAnimationEffect:duration:usingCompletionHandler:Pops the child view and updates the display using a given animation duration
Properties
attributedText
An attributed string with a message.
@property (strong, nonatomic) NSAttributedString *attributedTextDiscussion
This string will be show below the icon in a distance of the value set by iconTextMargin.
Declared In
CNBaseView.hbackgroundColor
Property to set the backgroundcolor of the view.
@property (assign, nonatomic) NSColor *backgroundColorDiscussion
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.hicon
An image that is shown centered of the view.
@property (strong, nonatomic) NSImage *iconDeclared In
CNBaseView.hiconTextMargin
@property (assign, nonatomic) CGFloat iconTextMarginDiscussion
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.hiconVerticalOffset
Float value to define a vertical offset for the icons view point.
@property (assign, nonatomic) CGFloat iconVerticalOffsetDiscussion
The default value is 10.0f.
Declared In
CNBaseView.hpreventDrawingWithSubviews
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 preventDrawingWithSubviewsParameters
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.htext
A string with a message.
@property (strong, nonatomic) NSString *textDiscussion
This string will be show below the icon in a distance of the value by iconTextMargin.
Declared In
CNBaseView.hInstance 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 *)attributedTextParameters
- icon
An
NSImageobject containing the icon.
- text
An
NSAttributedStringobject containing the text message with all the attributes you want.
Declared In
CNBaseView.hinitWithIcon:text:
- (id)initWithIcon:(NSImage *)icon text:(NSString *)textParameters
- icon
An
NSImageobject containing the icon.
- text
An
NSStringobject 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.hpopChildViewWithAnimationEffect: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 ))completionHandlerDiscussion
Animation effects are the same as described in popChildViewWithAnimationEffect:usingCompletionHandler:
Declared In
CNBaseView.hpopChildViewWithAnimationEffect:usingCompletionHandler:
Pops the child view and updates the display.
- (void)popChildViewWithAnimationEffect:(CNChildViewAnimationEffect)effect usingCompletionHandler:(void ( ^ ) ( void ))completionHandlerDeclared In
CNBaseView.hpushChildView: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 ))completionHandlerDiscussion
Animation effects are the same as described in pushChildView:withAnimationEffect:usingCompletionHandler:
Declared In
CNBaseView.hpushChildView:withAnimationEffect:usingCompletionHandler:
Pushs in another view as subview using the defined animation effect.
- (void)pushChildView:(NSView *)childView withAnimationEffect:(CNChildViewAnimationEffect)effect usingCompletionHandler:(void ( ^ ) ( void ))completionHandlerDiscussion
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