Adding Emboss to a UILabel in a navigationItem.titleView (as seen with navigationItem.title)

亡梦爱人 提交于 2019-12-30 01:39:05

问题


I'm trying to mimic the default emboss that automatically gets applied to navigationItem.title, as well as many other UIKit controls.

As seen in this screenshot's title ("Table Cells"):

Emboss title http://quicksnapper.com/files/3440/192219267049D92BB23DE74.png

I'm essentially trying to add 2 UILabels to the navigationItem.titleView, however the UILabels just show up as flatly drawn and it really just doesn't feel/look right :P

I've thought about playing with shadows, but that would only give the embossed look (if even that) on one side of the label.

Any ideas would be great!

Thanks


回答1:


Yeh thanks! I just figured it out:

where postTitle is set to a white colour, i just added a darkGray shadow with a vertical offset of 1px.

[postTitle setShadowColor:[UIColor darkGrayColor]];

[postTitle setShadowOffset:CGSizeMake(0, -1)];

Looks exactly like anything you'd put in a .title :)




回答2:


shadow and shadowOffset are what you're looking for I think. Set those properties on the label and it should do what you want.




回答3:


A white shadow and a plus one instead a minus one as offset gives that depressed embossed look.



来源:https://stackoverflow.com/questions/753822/adding-emboss-to-a-uilabel-in-a-navigationitem-titleview-as-seen-with-navigatio

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!