3
我從同事那裏得到了一個程序,他使用.xib文件來設置他的視圖。 (作爲一名核心編碼員,我從來沒有使用IB自己......) 因此,他設置了自己的ViewControler,並且他有一個NavBar(我在.xib文件中找不到)。將陰影添加到導航欄的標題
我想爲標題添加陰影。
如果我作出的NavBar,相對碼會是這樣的:
textViewTitle.layer.shadowOpacity = 2.0;
textViewTitle.layer.shadowRadius = 3.0;
textViewTitle.layer.shadowOffset = CGSizeMake(2.0, 3.0);
和工作正常。 周圍挖我發現,現在我需要用這個:
NSDictionary *navbarTtlAts = [NSDictionary dictionaryWithObjectsAndKeys:
[UIColor whiteColor], UITextAttributeTextColor,
[UIColor blackColor], UITextAttributeTextShadowColor,
[NSValue valueWithUIOffset:UIOffsetMake(2.0, 3.0)], UITextAttributeTextShadowOffset,
nil];
[self.navigationController.navigationBar setTitleTextAttributes:navbarTtlAts];
雖然這工作,我無法找到如何添加shadowOpacity & shadowRadius東西。
我發現我可以添加在NSDictionary的下面,但它沒有工作...
[NSNumber numberWithFloat: 2.0], @"shadowOpacity",
[NSNumber numberWithFloat: 3.0], @"shadowRadius",
任何想法?
請刪除除ios和objc以外的所有標籤。它會引起更多關注。 –