Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make button height customizable #191

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions Example/TSMessages/AlternativeDesign.json
Expand Up @@ -22,6 +22,7 @@
"borderColor": "#727C83",
"borderHeight": 1,
"buttonBackgroundImageName": "NotificationButtonBackground.png",
"buttonHeight": 17,
"buttonTitleTextColor": "#727C83",
"buttonTitleShadowColor": "#EBEEF1",
"buttonTitleShadowOffsetX": 0,
Expand Down
15 changes: 15 additions & 0 deletions Pod/Classes/TSMessage.m
Expand Up @@ -177,10 +177,23 @@ - (id)init
if ((self = [super init]))
{
_messages = [[NSMutableArray alloc] init];

[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(didRotate:)
name:UIDeviceOrientationDidChangeNotification
object:nil];
}
return self;
}

- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIDeviceOrientationDidChangeNotification object:nil];
}

- (void)didRotate:(NSNotification*)notification {
[self fadeInCurrentNotification];
}

- (void)fadeInCurrentNotification
{
if ([self.messages count] == 0) return;
Expand Down Expand Up @@ -331,6 +344,8 @@ - (void)fadeOutNotification:(TSMessageView *)currentView

- (void)fadeOutNotification:(TSMessageView *)currentView animationFinishedBlock:(void (^)())animationFinished
{
[[NSNotificationCenter defaultCenter] removeObserver:currentView name:UIDeviceOrientationDidChangeNotification object:nil];

currentView.messageIsFullyDisplayed = NO;
[NSObject cancelPreviousPerformRequestsWithTarget:self
selector:@selector(fadeOutNotification:)
Expand Down
16 changes: 13 additions & 3 deletions Pod/Classes/TSMessageView.m
Expand Up @@ -7,7 +7,7 @@
//

#import "TSMessageView.h"
#import "HexColor.h"
#import "HexColors.h"
#import "TSBlurView.h"
#import "TSMessage.h"

Expand Down Expand Up @@ -189,7 +189,7 @@ - (id)initWithTitle:(NSString *)title
alpha:1.0];


self.textSpaceLeft = 2 * padding;
self.textSpaceLeft = 17;
if (image) self.textSpaceLeft += image.size.width + 2 * padding;

// Set up title label
Expand Down Expand Up @@ -292,10 +292,14 @@ - (id)initWithTitle:(NSString *)title

self.button.contentEdgeInsets = UIEdgeInsetsMake(0.0, 5.0, 0.0, 5.0);
[self.button sizeToFit];
CGFloat buttonHeight = 31.0f;
if([current valueForKey:@"buttonHeight"]){
buttonHeight = [[current valueForKey:@"buttonHeight"] floatValue];
}
self.button.frame = CGRectMake(screenWidth - padding - self.button.frame.size.width,
0.0,
self.button.frame.size.width,
31.0);
buttonHeight);

[self addSubview:self.button];

Expand Down Expand Up @@ -355,6 +359,12 @@ - (id)initWithTitle:(NSString *)title
[self addGestureRecognizer:tapGesture];
}
}

self.layer.masksToBounds = NO;
self.layer.shadowOffset = CGSizeMake(0, 1);
self.layer.shadowRadius = 2;
self.layer.shadowOpacity = 0.2;

return self;
}

Expand Down