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

@ -136,7 +136,9 @@ import Foundation
owsFail("Missing button")
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
}

Loading…
Cancel
Save