Making Rounded UIView’ on iPhone

I have started developing (mainly) iPhone apps late 2009 and I feel like I have some experience on iOS platform that I can share. I won’t be doing tutorial serias but just some tips and tricks.

Let’s start with some ui tips, there are 2 ways to make rounded views in iPhone. One is using layers which is inefficient way, second is using quartz in drawRect.

Using layers is really simple;


YourView *vw = [[YourView alloc] initWithFrame:CGRectMake(20, 20, 80, 80)];
vw.layer.cornerRadius = 16;
vw.layer.masksToBounds = YES;

simple. The right way is to handle in drawRect;

UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:self.bounds byRoundingCorners:UIRectCornerAllCorners cornerRadii:CGSizeMake(16.0, 16.0)]; //Add a bezier path
[path addClip]; // and clip

Both two will same view.

iPhone 4S Camera Test 3

I see my blog turns into iPhone Blog but I like this device :) This weekend I took some photos from my new toy :) new photos are taken in a cloudy day. I’ll try to take samples from different light conditions.

About iPhone 4S Sim Failure & Batter Usage

There are hundreds of posts & thousands of page views about iPhone 4S Batter Life at Apple Support Forums. A few days, I’ve faced same problems a few days like I had no sim and sim failure errors, network losses and a few hours with full charge ! It seems problem is related directly with Apple but still there are solutions, at least two things worked for me;

1 – Changing SIM card with new one ( currently 64Kb micro sim ) solved network loss and sim failure errors.
2 – Turning off a few location based services;

  • Settings -> Location Services On -> Siri Off
  • Settings -> Location Services -> System Services -> Cell Network Search & Compass Calibration is On and everything else Off.

The result is surprising, my iphone batter is 70 % with 1 day standby and 1 hour usage.

Update

You can still have 2 days standby with a few hours usage.

iPhone 4S Camera Test 1

New iPhone’s camera is much better than expected, still I’m playing with camera. So, Its too early to evaluate and compare with other devices. What I want is to share two photos taken through this device.

RXTX PortInUseException on Mac OSX

This was my first serial programming experience on Mac OS X with Java and it was painful. There is no official library for Java for writing/reading from serial interface. Open source libraries available but those depends on OS, and OS architecture and java versions. After required libs installed, I had to get list of all port on my mac using rxtx however, had to deal with with PortInUseException while opening a port. Thanks to this guy; solution is to set up a folder and required permissions at location /var/lock, then everything went very well.

After a few years I returned back to java, it still same java nothing much here :) I can handle it.