4 ms·
One of the ObjC examples could be more concise. He writes: id navigationBar = [UINavigationBar appearance]; [navigationBar setBackgroundImage:[UIImage ima
by kenferry 14y ago
One of the ObjC examples could be more concise. He writes:
id navigationBar = [UINavigationBar appearance];
[navigationBar setBackgroundImage:[UIImage imageNamed:@"nav-background.png"] forBarMetrics:UIBarMetricsDefault];
[navigationBar setTitleTextAttributes:[[NSDictionary alloc] initWithObjectsAndKeys:
[UIFont cheddarFontWithSize:24.0f], UITextAttributeFont,
[UIColor colorWithWhite:0.0f alpha:0.4f], UITextAttributeTextShadowColor,
[UIColor whiteColor], UITextAttributeTextColor,
nil]];
which could be
id navigationBar = [UINavigationBar appearance];
[navigationBar setBackgroundImage:[UIImage imageNamed:@"nav-background.png"] forBarMetrics:UIBarMetricsDefault];
[navigationBar setTitleTextAttributes:@{
UITextAttributeFont : [UIFont cheddarFontWithSize:24],
UITextAttributeTextShadowColor : [UIColor colorWithWhite:0 alpha:0.4],
UITextAttributeTextColor : [UIColor whiteColor],
}];
as compares to the Ruby,
navigationBar = UINavigationBar.appearance
navigationBar.setBackgroundImage(UIImage.imageNamed('nav-background.png'), forBarMetrics: UIBarMetricsDefault)
navigationBar.setTitleTextAttributes({
UITextAttributeFont: UIFont.cheddarFontWithSize(24.0),
UITextAttributeTextShadowColor: UIColor.colorWithWhite(0.0, alpha:0.4),
UITextAttributeTextColor: UIColor.whiteColor
})
Also kind of wondering where he got "cheddarFont". :-)
- barrym 14y agoI didn't know about the new @{} syntax for dictionaries - http://blog.ablepear.com/2012/02/something-wonderful-new-objective-c.html http://blog.ablepear.com/2012/02/something-wonderful-new-obj... - very nice.
- samsoffes 14y agoYou can't use that unless you're running Mountain Lion and you can only submit apps to the store with a released version of Xcode. The new syntax is amazing though!
- rads 14y agoCheddar is the name of his app: https://cheddarapp.com/ https://cheddarapp.com/