Skip to content
This repository
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 107 lines (80 sloc) 2.868 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
//
// UAModalTitledDisplayPanelView.m
// UAModalPanel
//
// Created by Matt Coneybeare on 1/8/12.
// Copyright (c) 2012 Urban Apps. All rights reserved.
//

#import "UATitledModalPanel.h"
#import <QuartzCore/QuartzCore.h>

#define DEFAULT_TITLE_BAR_HEIGHT 40.0f

@implementation UATitledModalPanel

@synthesize titleBarHeight, titleBar, headerLabel;

- (void)dealloc {
    self.titleBar = nil;
self.headerLabel = nil;
    [super dealloc];
}

- (id)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        
self.titleBarHeight = DEFAULT_TITLE_BAR_HEIGHT;

CGFloat colors[8] = { 1, 1, 1, 1, 0, 0, 0, 1 };
self.titleBar = [UANoisyGradientBackground gradientWithFrame:CGRectZero
style:UAGradientBackgroundStyleLinear
color:colors
lineMode:UAGradientLineModeTopAndBottom
noiseOpacity:0.2
blendMode:kCGBlendModeNormal];

[self.roundedRect addSubview:self.titleBar];

self.headerLabel = [[[UILabel alloc] initWithFrame:CGRectZero] autorelease];
self.headerLabel.font = [UIFont systemFontOfSize:24];
self.headerLabel.backgroundColor = [UIColor clearColor];
self.headerLabel.textColor = [UIColor whiteColor];
self.headerLabel.shadowColor = [UIColor blackColor];
self.headerLabel.shadowOffset = CGSizeMake(0, -1);
self.headerLabel.textAlignment = UITextAlignmentCenter;
[self.titleBar addSubview:self.headerLabel];


    }
    return self;
}



- (CGRect)titleBarFrame {
CGRect frame = [self.roundedRect bounds];
return CGRectMake(frame.origin.x,
frame.origin.y + self.roundedRect.layer.borderWidth,
frame.size.width,
self.titleBarHeight - self.roundedRect.layer.borderWidth);
}


// overriding the subclass to make room for the title bar
- (CGRect)contentViewFrame {
CGRect titleBarFrame = [self titleBarFrame];
CGRect roundedRectFrame = [self roundedRectFrame];
CGFloat y = titleBarFrame.origin.y + titleBarFrame.size.height;
CGRect rect = CGRectMake(self.margin.left + self.padding.left,
self.margin.top + self.padding.top + y,
roundedRectFrame.size.width - self.padding.left - self.padding.right,
roundedRectFrame.size.height - y - self.padding.bottom - self.padding.bottom);
return rect;
}


- (void)layoutSubviews {
[super layoutSubviews];

self.titleBar.frame = [self titleBarFrame];
self.headerLabel.frame = self.titleBar.bounds;
}


// Overrides

- (void)showAnimationStarting {
self.contentView.alpha = 0.0;
self.titleBar.alpha = 0.0;
}

- (void)showAnimationFinished {
UADebugLog(@"Fading in content for modalPanel: %@", self);
[UIView animateWithDuration:0.2
delay:0.0
options:UIViewAnimationCurveEaseIn
animations:^{
self.contentView.alpha = 1.0;
self.titleBar.alpha = 1.0;
}
completion:nil];
}


@end
Something went wrong with that request. Please try again.