回覆列表
  • 1 # 使用者4243767351955

    見程式碼

    UIButton *btn=[UIButton buttonWithType:UIButtonTypeCustom];

    btn.frame = CGRectMake(0, 0, 44, 44);

    btn.adjustsImageWhenHighlighted = NO;

    [btn setImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];

    [btn addTarget:self action:Action forControlEvents:UIControlEventTouchUpInside];

    UIBarButtonItem *item=[[UIBarButtonItem alloc]initWithCustomView:btn];

    UIBarButtonItem *negativeSpacer = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil];

    negativeSpacer.width = -12;//ios7以後右邊距預設值18px,負數相當於右移,正數左移

    self.navigationItem.leftBarButtonItems=@[negativeSpacer,item];

  • 中秋節和大豐收的關聯?
  • 婆婆說:“該女人乾的活不要讓男人幹,別人會笑話”你們怎麼看?