1. 程式人生 > >button自動檢測 幾個字串之後能點選

button自動檢測 幾個字串之後能點選

UIButton *rightBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
    [rightBtn setImage:[UIImage themeImageNamed:@"nor"] forState:UIControlStateNormal];
    [rightBtn setImage:[UIImage themeImageNamed:@"press"] forState:UIControlStateHighlighted];
    [rightBtn addTarget:self action:@selector(clickToPublish) forControlEvents:UIControlEventTouchUpInside];
    
    UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithCustomView:rightBtn];
    item.enabled = self.model.title.length>0;
    self.navigationItem.rightBarButtonItem = item;