Finding the direction of scrolling in a UIScrollView?

I have a UIScrollView with only horizontal scrolling allowed, and I would like to know which direction (left, right) the user scrolls. What I did was to subclass the UIScrollView and override the touchesMoved method: – (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { [super touchesMoved:touches withEvent:event]; UITouch *touch = [touches anyObject]; float now = [touch locationInView:self].x; float … Read more

Binary operator ‘|’ cannot be applied to two UIViewAutoresizing operands

Getting this error in Swift 2.0. Binary operator ‘|’ cannot be applied to two UIViewAutoresizing operands Here is the code: let view = UIView(frame: CGRect(x: 0, y: 0, width: 320, height: 568)) addSubview(view) view.autoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight Any idea what can be the problem? 6 Answers 6

How to round the corners of a button

I have a rectangle image (jpg) and want to use it to fill the background of a button with rounded corner in xcode. I wrote the following: UIButton *button = [[UIButton buttonWithType:UIButtonTypeRoundedRect] retain]; CGRect frame = CGRectMake(x, y, cardWidth, cardHeight); button.frame = frame; [button setBackgroundImage:backImage forState:UIControlStateNormal]; However, the button I get with that approach doesn’t … Read more

How do I apply a perspective transform to a UIView?

I’m looking to perform a perspective transform on a UIView (such as seen in coverflow) Does anyonew know if this is possible? I’ve investigated using CALayer and have run through all the pragmatic programmer Core Animation podcasts, but I’m still no clearer on how to create this kind of transform on an iPhone. Any help, … Read more

Have a reloadData for a UITableView animate when changing

I have a UITableView that has two modes. When we switch between the modes I have a different number of sections and cells per section. Ideally, it would do some cool animation when the table grows or shrinks. Here is the code I tried, but it doesn’t do anything: CGContextRef context = UIGraphicsGetCurrentContext(); [UIView beginAnimations:nil … Read more