Question

I am trying to create a shopping cart application , Now on adding any product i want to add badge on a UIButton which will increase or decrease accordingly .

I searched google but end up with the solution " MKNumberBadgeView " (https://www.cocoacontrols.com/controls/mknumberbadgeview)

I am creating application that supports iPhone4/5 so i am afraid to add a sub view in my view controller and manage on iPhone 4 & 5.

can any one suggest a better solution so that i can get a badge on UIButton along which also supports orientation . or a Solution to Handle subview for Both devices 4 & 5.

Thanks in advance .

Was it helpful?

Solution

Managing whether it is an iPhone 4 or 5 is not a ton of work, it really only makes a difference when you initialize the button and that is it.

You can do this by getting the screen size using the following code

CGRect screenBounds = [[UIScreen mainScreen] bounds];
if (screenBounds.height == 568) {
    // This is an iPhone 5
} else if (screenBounds.height == 480) {
    // This is an iPhone 4S or below
} else {
    // Some other device, maybe an iPad?
}

Then just add the button in that way, pretty straightforward

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top