Drawing Rectangles in iOS

Bryce Langlotz picture Bryce Langlotz · Feb 9, 2013 · Viewed 40.3k times · Source

My goal for my app is for the user to be able to sort through different scheduling options by swiping to the left and right of an iPhone screen. How would I draw and remove rectangles as the user sorts through these different scheduling options?

I have a UIViewController.h, UIViewController.m, and UIViewController.xib files to manipulate. Do I need a separate UIView class? If so, how do I connect that UIView class to the view in my .xib file?

Answer

Wilson Soethe Cursino picture Wilson Soethe Cursino · Aug 1, 2014

Wow... so many complicated solution, here is what you need:

UIView *myBox  = [[UIView alloc] initWithFrame:CGRectMake(180, 35, 10, 10)];
myBox.backgroundColor = [UIColor lightGrayColor];
[self.view addSubview:myBox];

Nothing else... don't need to go crazy on the implementation.