Create Flat UI rounded button class.

// FREEBIE
pull/1/head
Matthew Chen 8 years ago
parent 5be2014ec7
commit 3993035d98

@ -198,21 +198,23 @@
UITableViewCell *cell = [UITableViewCell new]; UITableViewCell *cell = [UITableViewCell new];
cell.preservesSuperviewLayoutMargins = YES; cell.preservesSuperviewLayoutMargins = YES;
cell.contentView.preservesSuperviewLayoutMargins = YES; cell.contentView.preservesSuperviewLayoutMargins = YES;
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; cell.selectionStyle = UITableViewCellSelectionStyleNone;
button.backgroundColor = [UIColor ows_destructiveRedColor];
[button setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal]; const CGFloat kButtonHeight = 40.f;
[button setTitle:NSLocalizedString(@"SETTINGS_DELETE_ACCOUNT_BUTTON", @"") forState:UIControlStateNormal]; OWSFlatButton *button = [OWSFlatButton buttonWithTitle:NSLocalizedString(@"SETTINGS_DELETE_ACCOUNT_BUTTON", @"")
button.titleLabel.font = [UIFont ows_mediumFontWithSize:18.f]; font:[OWSFlatButton fontForHeight:kButtonHeight]
button.titleLabel.textAlignment = NSTextAlignmentCenter; titleColor:[UIColor whiteColor]
backgroundColor:[UIColor ows_destructiveRedColor]
target:self
selector:@selector(unregisterUser)];
[cell.contentView addSubview:button]; [cell.contentView addSubview:button];
[button autoSetDimension:ALDimensionHeight toSize:50.f]; [button autoSetDimension:ALDimensionHeight toSize:kButtonHeight];
[button autoVCenterInSuperview]; [button autoVCenterInSuperview];
[button autoPinLeadingAndTrailingToSuperview]; [button autoPinLeadingAndTrailingToSuperview];
[button addTarget:self action:@selector(unregisterUser) forControlEvents:UIControlEventTouchUpInside];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell; return cell;
} }
customRowHeight:100.f customRowHeight:90.f
actionBlock:nil]]; actionBlock:nil]];
[contents addSection:section]; [contents addSection:section];

@ -136,7 +136,9 @@ import Foundation
owsFail("Missing button") owsFail("Missing button")
return return
} }
button.layer.cornerRadius = ScaleFromIPhone5To7Plus(4, 5) // To my eye, this radius tends to look right regardless of button size
// (within reason) or device size.
button.layer.cornerRadius = 5
button.clipsToBounds = true button.clipsToBounds = true
} }

Loading…
Cancel
Save