title: How to change the position of the button through coding xcode
body: <p>I am trying to align a button that I created through code, but I can't seem to change its position, my code:</p>
  
  <pre><code>- (id)initWithFrame:(CGRect)frame
  {
      self = [super initWithFrame:frame];
      if (self) {
          self.backgroundColor = [UIColor whiteColor];
          self.lineWidth = DEFAULT_WIDTH;
          self.lineColor = DEFAULT_COLOR;
          UIButton* btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
          btn.frame = CGRectMake(20,100, 50, 50);
          //[btn setFrame:CGRectMake(3,20, 50, 50)];
          btn.center = self.center;
  
          [btn setTitle:@"Clear" forState:UIControlStateNormal];
          [btn addTarget: self 
                     action: @selector(clearButtonPressed:) 
           forControlEvents: UIControlEventTouchDown];
          [self addSubview:btn];
      }
      return self;
  }
  </code></pre>
  
  <p>If I remove the "btn.center =self.center" and try to set the X and Y position as</p>
  
  <pre><code>    "btn.frame =CGRectMake(3,20,50,50)"
  </code></pre>
  
  <p>it doesn't even display the button.
  Please any help will be appreciated , thanks in advance!</p>