Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UIButton title blurry #66

Open
raytrodd opened this issue Sep 21, 2011 · 4 comments
Open

UIButton title blurry #66

raytrodd opened this issue Sep 21, 2011 · 4 comments

Comments

@raytrodd
Copy link

I am running into an issue where a UIButton with a simple title is being shown with blurry text. The code below renders a UILabel and an UIButton with the same font name and size. The UILabel shows is rendered clearly, but the UIButton appears blurry:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
  window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].applicationFrame];
  window.backgroundColor = [UIColor lightGrayColor];
  window.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
  
  
  UILabel* sillyLabel = [[UILabel alloc] init];
  sillyLabel.text = @"silly label";
  sillyLabel.font = [UIFont fontWithName:@"Helvetica" size:12];
  sillyLabel.textColor = [UIColor darkGrayColor];
  sillyLabel.frame = CGRectMake(22, 100, 60, 50);
  sillyLabel.backgroundColor = [UIColor clearColor];
  [window addSubview:sillyLabel];
  
  UIButton* sillyButton = [UIButton buttonWithType:UIButtonTypeCustom];
  sillyButton.titleLabel.textAlignment = UITextAlignmentLeft;
  [sillyButton setTitle:@"silly button" forState:UIControlStateNormal];
  [sillyButton setTitleColor:[UIColor darkGrayColor] forState:UIControlStateNormal];
  sillyButton.titleLabel.font = [UIFont fontWithName:@"Helvetica" size:12];
  sillyButton.frame = CGRectMake(22,125,60, 50);
  [window addSubview:sillyButton];
  
  
  [window makeKeyAndVisible];
    return YES;
}

I verified that this code results in the correct behavior in iOS.

@raytrodd
Copy link
Author

This appears to be related to the _defaultTitleShadowColor. When a shadowColor is not specified, UIButton is defaulting to white. This seems to cause the symptom detailed above. I made this change locally, and the buttons appear the same on ios and chameleon.

 - (UIColor *)_defaultTitleShadowColor
 {
-    return [UIColor whiteColor];
+    return nil;
 }

@ghost
Copy link

ghost commented Oct 9, 2011

what's happening if you force to render on the pixel grid?

CGRectMake(22.5f, 100.5f ...

@raytrodd
Copy link
Author

It looks better, but it still looks smudged and quite different than the normal ios rendering.

@ghost
Copy link

ghost commented Oct 17, 2011

Quartz is a different animal for different purposes iOS rendering is doing a lot to help kidos, on the the desktop you have to be mature, let's say do the same for your super container? I am sure your button is in handmade container, moreover it would be foolish to think to get the same rendering as the screens are physically quite different, say pixel wide for instance.

to accomplish this facsimile, this UKKit port should relay on a CoreGraphics placeholder where frames and bounds shadows rendering are adapted to auto-correct the developer "inputs" like the iOS does and for my taste too much, but Apple wanted to attract a large number of devs even the less gifted.

here we are typically in what we call cross platform developments, it's like the web, different browsers, different platforms, but your code has to take account of the reality else you don't get paid.

You should read more about Quartz 2D and PostScript rendering, and here is the mistake logging that as an issue because you did not take account that Quartz is a different Graphic engine with its own logics, this UIKit port is not meant to do your job, it's a set of class wrapping the UIKit hierarchy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant