Posts

Showing posts from September, 2020

How to display different type of cells in a UITableview in swift?

Image
Recently I had a project where I have to display different types of components as a listing. At the beginning the project requirements was to have a simple setup. Maximum 2 component per view. Yeah easy enough. I created custom xib files per component so I can load them up, mix them up whenever I want. By the way the overall layout was controlled by the API server so the design will be sent out from the server, so I have to layout components accordingly. If anyone wondering what a component is, below image is will give you an idea.               Since we can control the interface from the API they added more and more component in to the layout. This is where I started to realize the design flow. The more components we added, the system started to lose the performance. It not only decreases the performance but also started the crash the app whenever user switch the orientation. At this point I realized I need to come up with a way to reuse the component...

How to create app icons easy using Sips

Image
One of the daunting things when it comes to publishing apps is to create app icons. We have almost 18 app icons needs to be generated for a single app. If you ask me most of the graphic designers hate this job. Luckily apple have provided a tool with Mac OS X since the release of Mac OS X 13.3 which most of us don’t know about. It’s called Sips . This is a very easy to use straightforward tool but works only on the terminal. Using this tool you only need the high resolution 1024x1024px image to generate all the other icons.   sips app_icon_1024x1024.png -z 40 40 --out app_icon_40x40.png You can replace 40 40 for any height and width to generate different icons. Example : sips app_icon_1024x1024.png -z 60 60 --out app_icon_60x60.png sips app_icon_1024x1024.png -z 58 58 --out app_icon_58x58.png So next time if you want to generate app icons you can use this tool to make your life easy :)

How to know iPad is in landscape on orientation change using trait collections?

 Trait collections are really helpful to create adaptive interfaces to adjust your apps layout according to the orientation changes. Simply said trait collection will inform you the current device size according to the device orientation. This is really useful for us because assume you want to change the collection view layout from one column to two column on landscape or change image size according to the orientation. Apple has given us a handy method to know exactly when the trait collection change so we can catch that event and adjust our layout accordingly. override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {         super.traitCollectionDidChange(previousTraitCollection) } The problem with trait collection is that in iPad this method will not fire on orientation change because horizontal and vertical size classes are same for landscape and portrait. https://developer.apple.com/documentation/uikit/uitraitcoll...