title: UIView not getting touchesbegan called
body: <p>There are a number of other issues for this but none of the solutions seem to be working for me. I'm very new to iOS - currently working on a problem from the Big Nerd Ranch iOS Programming book.</p>
  
  <p>Most of the SOs I found said the issue ended up being <code>userInteractionEnabled = YES</code> was missing. Or the view's background was set to <code>transparent</code>. But removing the transparent background and setting <code>userInteractionEnabled = YES</code> did not result in the event firing. Any ideas what I'm missing?</p>
  
  <p>AppDelegate.m:</p>
  
  <pre><code>#import "AppDelegate.h"
  #import "BNRHypnosisView.h"
  #import "ViewController.h"
  
  @interface AppDelegate ()
  
  @end
  
  @implementation AppDelegate
  
  
  - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
      // Override point for customization after application launch.
      self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
  
      CGRect firstFrame = self.window.bounds;
  
      BNRHypnosisView *firstView = [[BNRHypnosisView alloc] initWithFrame:firstFrame];
      firstView.userInteractionEnabled = YES;
  
      ViewController *controller = [[ViewController alloc] init];
      [self.window setRootViewController:controller];
      [self.window addSubview:firstView];
  
      self.window.backgroundColor = [UIColor whiteColor];
  
      [self.window makeKeyAndVisible];
  
      return YES;
  }
  </code></pre>
  
  <p>BNRHypnosisView.m:</p>
  
  <pre><code>#import "BNRHypnosisView.h"
  
  @interface BNRHypnosisView()
  
  @property (strong, nonatomic) UIColor *circleColor;
  
  @end
  
  @implementation BNRHypnosisView
  -(void)drawRect:(CGRect)rect {
      CGRect bounds = self.bounds;
  
      CGPoint center;
      center.x = bounds.origin.x + bounds.size.width / 2.0;
      center.y = bounds.origin.y + bounds.size.height / 2.0;
  
      float maxRadius = hypot(bounds.size.width, bounds.size.height) / 2.0;
      UIBezierPath *path = [[UIBezierPath alloc] init];
  
      for (float currentRadius = maxRadius; currentRadius &gt; 0; currentRadius -=20) {
          [path moveToPoint:CGPointMake(center.x + currentRadius, center.y)];
  
          [path addArcWithCenter:center radius:currentRadius startAngle:0.0 endAngle:M_PI * 2.0 clockwise:YES];
      }
  
      path.lineWidth = 10;
  
      [self.circleColor setStroke];
  
      [path stroke];
  }
  
  -(instancetype)initWithFrame:(CGRect)frame {
      self = [super initWithFrame:frame];
      if (self) {
          self.backgroundColor = [UIColor clearColor];
          self.circleColor = [UIColor lightGrayColor];
      }
      return self;
  }
  
  -(void)touchesBegan:(NSSet&lt;UITouch *&gt; *)touches withEvent:(UIEvent *)event {
      NSLog(@"%@ was touched", self);
  
      float red = (arc4random() % 100) / 100.0;
      float green = (arc4random() % 100) / 100.0;
      float blue = (arc4random() % 100) / 100.0;
  
      UIColor *randomColor = [UIColor colorWithRed:red green:green blue:blue alpha:1.0];
  
      self.circleColor = randomColor;
  }
  </code></pre>
  
  <p>Screenshot of app:
  <a href="https://i.stack.imgur.com/l7USS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/l7USS.png" alt="enter image description here"></a></p>
  
  <p>Screenshot of view debugger<a href="https://i.stack.imgur.com/2AmiS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2AmiS.png" alt="enter image description here"></a></p>