From 3993035d9830a020f47cbb5b63efdf29c4822f5a Mon Sep 17 00:00:00 2001 From: Matthew Chen Date: Tue, 12 Sep 2017 10:27:22 -0400 Subject: [PATCH] Create Flat UI rounded button class. // FREEBIE --- .../AppSettingsViewController.m | 22 ++++++++++--------- Signal/src/views/OWSFlatButton.swift | 4 +++- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/Signal/src/ViewControllers/AppSettingsViewController.m b/Signal/src/ViewControllers/AppSettingsViewController.m index 0f6262e8a..a7e1bdbd1 100644 --- a/Signal/src/ViewControllers/AppSettingsViewController.m +++ b/Signal/src/ViewControllers/AppSettingsViewController.m @@ -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]; diff --git a/Signal/src/views/OWSFlatButton.swift b/Signal/src/views/OWSFlatButton.swift index e65252811..348e28c8f 100644 --- a/Signal/src/views/OWSFlatButton.swift +++ b/Signal/src/views/OWSFlatButton.swift @@ -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 }