Created
February 13, 2012 01:52
-
-
Save tikitikipoo/1812628 to your computer and use it in GitHub Desktop.
UIToolbarに背景画像を設定。iOS5とiOS4に対応する方法。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 出所:http://stackoverflow.com/questions/6341503/uinavigationbar-custom-background-image | |
// 関連:http://www.mladjanantic.com/setting-custom-background-for-uinavigationbar-what-will-work-on-ios5-and-ios4-too/ | |
toolBar = [[UIToolbar alloc] initWithFrame:toolBarBounds]; | |
[toolBar sizeToFit]; | |
// set BackgroudImage | |
if ([[[UIDevice currentDevice] systemVersion] floatValue] > 4.9) { | |
//iOS 5 | |
if ([toolBar respondsToSelector:@selector(setBackgroundImage:forToolbarPosition:barMetrics:)]) { | |
[toolBar setBackgroundImage:[UIImage imageNamed: @"black.png"] | |
forToolbarPosition:UIToolbarPositionAny | |
barMetrics:UIBarMetricsDefault]; | |
} | |
} else { | |
//iOS 4 | |
[toolBar insertSubview:[[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"black.png"]] autorelease] atIndex:0]; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment