【问题标题】:Make custom Navigation Buttons glow when touched?使自定义导航按钮在触摸时发光?
【发布时间】:2013-08-02 20:48:50
【问题描述】:

在我的导航栏中,我有两个右键栏项目。一个是自定义按钮,另一个使用信息灯按钮类型。两者都很好,但我想让自定义按钮具有默认发光,就像你触摸它时信息按钮一样。这可能吗?

// Default info light btn
UIButton *infoBtn = [UIButton buttonWithType:UIButtonTypeInfoLight];
UIBarButtonItem *infoBtnItem = [[UIBarButtonItem alloc]initWithCustomView:infoBtn];

// Custom Btn
UIButton *customButton = [UIButton buttonWithType:UIButtonTypeCustom];
[customButton setFrame:CGRectMake(0, 0, btnImage.size.width, btnImage.size.height)];
[customButton setBackgroundImage:btnImage forState:UIControlStateNormal];
[customButton addTarget:self action:@selector(rightDrawerButtonPress:) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *customButtonItem = [[UIBarButtonItem alloc] initWithCustomView:wlButton];

NSArray *rightBtns = @[customButtonItem, infoBtnItem];
[navItem setRightBarButtonItems:rightBtns animated:YES];

【问题讨论】:

    标签: ios ios6 uibutton uinavigationbar uibarbuttonitem


    【解决方案1】:

    你只需要多写一行代码:-

    customButton.showsTouchWhenHighlighted = TRUE;
    

    在此之后你的代码输出如下:-

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多