Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Does anyone know how rounded corners like this can be applied in practice?


The easiest way is to use a custom full-sized background for the tab bar, navigation bar and toolbars.


I haven't tried it, but you should be able to set the cornerRadius of the layer (a CALayer) of the main window. That would apply it to all subviews.


This works, but setting the cornerRadius property kills performance. It's preferable to overlay an image with black corners or to bake the black corners into your art assets.


CALayer masking on the main window will cause the entire window to be rendered offscreen, which isn't going to be usable for even the most basic app on a real device.

I'd recommend either baking the corners into your art assets (for your NavigationBar, Toolbar, TabBar backgrounds), or overriding drawRect on the NavigationBar and Toolbar and adding a clip. Most apps I've worked on end up demanding a custom NavigationBar and Toolbar anyway, so there's not much reason not to do this.

If a truly abstract solution was really necessary (i.e. "I need 4 round corners absolutely everywhere, and I don't have custom art assets"), I think the easiest way would be to create four "round corner" image views and add them to a subview of the application delegate's UIWindow. This would also be much faster than masking the layer, as it'd create four small GPU-accelerated blend areas rather than one giant offscreen view to upload every frame. The main drawback (and the reason why I suggest the art asset version instead) is that orientation and bounds changes have to be handled manually for added subviews of UIWindow.


I just confirmed that this does work. Note, however, that you'll also need to set clipsToBounds to YES on the window.


It's already been done years ago in the jailbreak scene e.g ‘RoundCorners’ Blesses iPhone Owners With a Well Rounded Experience http://www.idownloadblog.com/2011/01/05/roundcorners-blesses...

NB: rounded corners was itself a copy of the webOS viewport system.


"Rectangles with rounded corners are everywhere! Just look around this room! And look outside, there's even more, practically everywhere you look!" —Steve Jobs, 1981

http://www.folklore.org/StoryView.py?story=Round_Rects_Are_E...

Also: http://interuserface.net/2011/06/own-a-shape/


> NB: rounded corners was itself a copy of the webOS viewport system.

Rounded corners have been a part of Apple's design for the entirety of the Mac's life. Only "recently" in Mac OS X has the Finder not had rounded corners. Those widget apps, such as Calculator, also had rounded corners way back when.

That said, it does seem very similar to WebOS's beautiful design. But who's borrowed from who? And does it really matter?




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: