Re: Control default color inconsistencies
Re: Control default color inconsistencies
- Subject: Re: Control default color inconsistencies
- From: Andreas Falkenhahn <email@hidden>
- Date: Wed, 14 Dec 2016 18:38:26 +0100
On 14.12.2016 at 17:54 じょいすじょん wrote:
> Nobody can guess what you are actually doing.
> Please share some code so people can help you.
There is not much code to share. My code just creates UILabel, UIButton,
and UITableView with absolutely minimal customization, the intention
being to check out the default look of those controls. But, as I wrote in
my last mail, this default look is pretty confusing and irritating because
background and foreground color aren't consistent at all.
I'd like to avoid hard-coding specific colors as this is bad GUI coding
practice on the desktop systems I come from. I'd like iOS to use the
default colors instead but I'm not sure how to do this.
For reference, here is how I create the objects:
UIScreen *myScreen = [UIScreen mainScreen];
CGRect rect = [myScreen bounds];
// results in a UILabel that has black background and foreground, i.e. text is unreadable
UILabel *header1 = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, rect.size.width, 48)];
header1.text = @"Label test";
[self.view addSubview:header1];
// results in gray background with black text
UITableView *tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 48, rect.size.width, rect.size.height - (48 + 80))];
tableView.dataSource = self;
tableView.delegate = self;
tableView.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth;
[tableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"Cell"];
[tableView reloadData];
[self.view addSubview:tableView];
// results in black background with blue label text
UIButton *optionsButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[optionsButton addTarget:self action:@selector(clickOptions:) forControlEvents:UIControlEventTouchUpInside];
[optionsButton setFrame:CGRectMake(0, rect.size.height - 80, rect.size.width, 80)];
[optionsButton setTitle:@"Button test" forState:UIControlStateNormal];
[optionsButton setExclusiveTouch:YES];
[self.view addSubview:optionsButton];
The controls are created in a UIViewController inside the viewDidLoad() method. This
UIViewController is then set as the UIWindow's rootViewController.
--
Best regards,
Andreas Falkenhahn mailto:email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden