Created
October 28, 2015 21:49
-
-
Save emkman/5cf70032d72e3cc98feb to your computer and use it in GitHub Desktop.
add custom buttons/views to ATLConversationViewController
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)addActionButtons { | |
CGRect toolbarFrame = self.messageInputToolbar.frame; | |
int seperatorWidth = 16; | |
UIToolbar *toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, -(toolbarFrame.size.height+5), self.view.frame.size.width, 50)]; | |
UIButton *declineButton = [UIButton buttonWithType:UIButtonTypeCustom]; | |
toolbar.backgroundColor = [UIColor colorWithRed:255.0 green:255.0 blue:255.0 alpha:1]; | |
[declineButton addTarget:self action:@selector(declineWasTapped:)forControlEvents:UIControlEventTouchUpInside]; | |
declineButton.frame = CGRectMake(0, -20, toolbarFrame.size.width/2, 50); | |
[declineButton setTitle:@"Decline" forState:UIControlStateNormal]; | |
[declineButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; | |
[[declineButton layer] setBorderWidth:.5]; | |
[[declineButton layer] setBorderColor:[UIColor colorWithRed:0.706 green:0.706 blue:0.745 alpha:1.000].CGColor]; | |
declineButton.titleLabel.font = [UIFont fontWithName:@"ProximaNova-Regular" size:18]; | |
[declineButton setTitleColor:[UIColor colorWithRed:0.706 green:0.706 blue:0.745 alpha:1.000] forState:UIControlStateNormal]; | |
UIBarButtonItem *declineItem = [[UIBarButtonItem alloc] initWithCustomView:declineButton]; | |
UIButton *acceptButton = [UIButton buttonWithType:UIButtonTypeCustom]; | |
[acceptButton addTarget:self action:@selector(acceptWasTapped:)forControlEvents:UIControlEventTouchUpInside]; | |
acceptButton.frame = CGRectMake(toolbarFrame.size.width/2, 0, toolbarFrame.size.width/2, 50); | |
[acceptButton setTitle:@"Accept" forState:UIControlStateNormal]; | |
[acceptButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; | |
[[acceptButton layer] setBorderWidth:.5]; | |
[[acceptButton layer] setBorderColor:[UIColor colorWithRed:0.706 green:0.706 blue:0.745 alpha:1.000].CGColor]; | |
acceptButton.titleLabel.font = [UIFont fontWithName:@"ProximaNova-Semibold" size:18]; | |
[acceptButton setTitleColor:[UIColor colorWithRed:0.405 green:0.821 blue:0.784 alpha:1.000] forState:UIControlStateNormal]; | |
UIBarButtonItem *acceptItem = [[UIBarButtonItem alloc] initWithCustomView:acceptButton]; | |
UIBarButtonItem *negativeSeparator = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil]; | |
negativeSeparator.width = -seperatorWidth; | |
UIBarButtonItem *negativeSeparatorTwo = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil]; | |
negativeSeparatorTwo.width = -(seperatorWidth - 5); | |
UIBarButtonItem *positiveSeparator = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil]; | |
positiveSeparator.width = seperatorWidth; | |
[toolbar setItems:[NSArray arrayWithObjects:negativeSeparator, declineItem, negativeSeparatorTwo, acceptItem, nil]]; | |
[self.messageInputToolbar.superview addSubview:toolbar]; | |
// [self.messageInputToolbar.superview bringSubviewToFront:toolbar]; | |
self.actionButtons = toolbar; | |
// self.messageInputToolbar.translatesAutoresizingMaskIntoConstraints = NO; | |
// | |
// [self.messageInputToolbar.superview addConstraint:[NSLayoutConstraint constraintWithItem:toolbar attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.messageInputToolbar attribute:NSLayoutAttributeTop multiplier:1.0f constant:0.0f]]; | |
//[self.messageInputToolbar.superview layoutIfNeeded]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment