title: Why -frameForAlignmentRect: and -alignmentRectForFrame: not calling on IOS
body: <p>I want to use <code>-frameForAlignmentRect:</code> and <code>-alignmentRectForFrame:</code> to specify alignment rects in my iOS apps. But this methods not calling.</p>
  
  <p>I have almost identical code for iOS and Mac. It is works perfectly on OS X but not on iOS.</p>
  
  <h3>Mac version</h3>
  
  <pre><code>@implementation CustomView
  
  #define SHADOW_SIZE 10
  
  - (void)drawRect:(NSRect)dirtyRect {
      NSBezierPath *path;
  
      [[NSColor redColor] set];
      path = [NSBezierPath bezierPathWithRect:dirtyRect];
      [path fill];
  
      // Draw a shadow
      NSRect rect = NSMakeRect(SHADOW_SIZE, 0, dirtyRect.size.width - SHADOW_SIZE, dirtyRect.size.height - SHADOW_SIZE);
      path = [NSBezierPath bezierPathWithRoundedRect:rect xRadius:32 yRadius:32];
      [[[NSColor blackColor] colorWithAlphaComponent:0.3f] set];
      [path fill];
  
      // Draw shape
      rect.origin = CGPointMake(0, SHADOW_SIZE);
      path = [NSBezierPath bezierPathWithRoundedRect:rect xRadius:32 yRadius:32];
  
      [[NSColor orangeColor] set];
      [path fill];
  }
  
  #define USE_ALIGNMENT_RECTS 1
  
  #if USE_ALIGNMENT_RECTS
  - (NSRect)frameForAlignmentRect:(NSRect)alignmentRect {
      NSRect rect = alignmentRect;
      rect.origin.y -= SHADOW_SIZE;
      rect.size.width += SHADOW_SIZE;
      rect.size.height += SHADOW_SIZE;
      return rect;
  }
  
  - (NSRect)alignmentRectForFrame:(NSRect)frame {
     NSRect rect;
      rect.origin = CGPointMake(frame.origin.x, frame.origin.y + SHADOW_SIZE);
      rect.size.width = frame.size.width - SHADOW_SIZE;
      rect.size.height = frame.size.height - SHADOW_SIZE;
      return rect;
  }
  #endif
  @end
  
  @implementation AppDelegate
  
  - (void)awakeFromNib {
  
      _view = _window.contentView;
  
      CustomView *view = [[CustomView alloc] init];
      [self.view addSubview:view];
  
      view.translatesAutoresizingMaskIntoConstraints = NO;
  
  
      // Set vertical and horizontal alignments and view size
      // A little trick from here https://github.com/evgenyneu/center-vfl
  
      NSDictionary *views = NSDictionaryOfVariableBindings(_view, view);
      [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:[_view]-(&lt;=1)-[view(200)]"
                                                                 options:NSLayoutFormatAlignAllCenterY
                                                                 metrics:nil
                                                                   views:views]];
  
      [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[_view]-(&lt;=1)-[view(200)]"
                                                                    options:NSLayoutFormatAlignAllCenterX
                                                                    metrics:nil
                                                                      views:views]];
  }
  
  @end
  </code></pre>
  
  <h3>iOS version</h3>
  
  <pre><code>@implementation MyView
  
  #define SHADOW_SIZE 10
  
  - (void)drawRect:(CGRect)dirtyRect {
      UIBezierPath *path;
  
      [[UIColor redColor] set];
      path = [UIBezierPath bezierPathWithRect:dirtyRect];
      [path fill];
  
      // Draw a shadow
      CGRect rect = CGRectMake(SHADOW_SIZE, SHADOW_SIZE, dirtyRect.size.width - SHADOW_SIZE, dirtyRect.size.height - SHADOW_SIZE);
      path = [UIBezierPath bezierPathWithRoundedRect:rect cornerRadius:32];
      [[[UIColor blackColor] colorWithAlphaComponent:0.3f] set];
      [path fill];
  
      // Draw shape
      rect.origin = CGPointMake(0, 0);
      path = [UIBezierPath bezierPathWithRoundedRect:rect cornerRadius:32];
      [[UIColor orangeColor] set];
      [path fill];
  }
  
  #define USE_ALIGNMENT_RECTS 1
  #define USE_ALIGNMENT_INSETS 1
  
  #if USE_ALIGNMENT_RECTS
  - (CGRect)frameForAlignmentRect:(CGRect)alignmentRect {
      CGRect rect = alignmentRect;
      rect.size.width += SHADOW_SIZE;
      rect.size.height += SHADOW_SIZE;
      return rect;
  }
  
  - (CGRect)alignmentRectForFrame:(CGRect)frame {
      CGRect rect = frame;
      rect.size.width = frame.size.width - SHADOW_SIZE;
      rect.size.height = frame.size.height - SHADOW_SIZE;
      return rect;
  }
  #endif
  
  #if USE_ALIGNMENT_INSETS
  - (UIEdgeInsets)alignmentRectInsets {
      return UIEdgeInsetsMake(0, 0, SHADOW_SIZE, SHADOW_SIZE);
  }
  #endif
  
  @end
  
  @implementation ViewController
  
  - (void)viewDidLoad {
      [super viewDidLoad];
  
      MyView *view = [[MyView alloc] init];
      [self.view addSubview:view];
  
      view.translatesAutoresizingMaskIntoConstraints = NO;
  
      UIView *superview = self.view;
      NSDictionary *views = NSDictionaryOfVariableBindings(superview, view);
      [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:[superview]-(&lt;=1)-[view(200)]"
                                                                    options:NSLayoutFormatAlignAllCenterY
                                                                    metrics:nil
                                                                      views:views]];
  
      [self.view addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[superview]-(&lt;=1)-[view(200)]"
                                                                    options:NSLayoutFormatAlignAllCenterX
                                                                    metrics:nil
                                                                      views:views]];
  }
  
  @end
  </code></pre>
  
  <p>As you can see iOS version has also <code>-alignmentRectInsets:</code> which works well, but i want to figure out whats wrong with <code>-frameForAlignmentRect:</code> and <code>-alignmentRectForFrame:</code> methods.</p>