[shareButton.widthAnchor constraintEqualToConstant:25].active = YES;
[shareButton.heightAnchor constraintEqualToConstant:25].active = YES;
UIImage *shareImg = [UIImage imageNamed:@"YQCRMResource.bundle/share"];
UIImage *editImg = [UIImage imageNamed:@"YQCRMResource.bundle/edit"];
// 分享
UIButton *shareButton=[UIButton buttonWithType:UIButtonTypeCustom];
shareButton.frame = CGRectMake(0, 0, 40, 40);
[shareButton.widthAnchor constraintEqualToConstant:25].active = YES;
[shareButton.heightAnchor constraintEqualToConstant:25].active = YES;
[shareButton setBackgroundImage:shareImg forState:UIControlStateNormal];
[shareButton addTarget:self action:@selector(shareItemClick:) forControlEvents:UIControlEventTouchUpInside];
// 编辑
UIButton *editButton=[UIButton buttonWithType:UIButtonTypeCustom];
[editButton addTarget:self action:@selector(editItemClick:) forControlEvents:UIControlEventTouchUpInside];
[editButton setBackgroundImage:editImg forState:UIControlStateNormal];
editButton.frame=CGRectMake(0, 0, 40, 40);
[editButton.widthAnchor constraintEqualToConstant:25].active = YES;
[editButton.heightAnchor constraintEqualToConstant:25].active = YES;
UIBarButtonItem *shareItem = [[UIBarButtonItem alloc] initWithCustomView:shareButton];
UIBarButtonItem *editItem = [[UIBarButtonItem alloc] initWithCustomView:editButton];
[self.navigationItem setRightBarButtonItems:[NSArray arrayWithObjects: shareItem, editItem,nil]];
网友评论