UIButton has a point when it is selected inside UIToolbar

I add UIButtonto UIToolbar, which I do not want to have in quality UIBarButtonItem, so that I have more control over the position UIButtoninside the frame. I assigned a different name for the "Normal" and "Selected" states. Everything acts perfectly fine for UIButton, except when in the "Selected" there is a dot with 1 pixel in front of the header UIButton.

Toolbar:

    UIToolbar *customView = [[UIToolbar alloc] initWithFrame:CGRectMake(HEADER_MARGIN, 0, HEADER_WIDTH, HEADER_HEIGHT)];
[customView setBarTintColor:[UIColor whiteColor]];

button:

UIButton *listOrderButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, ORDER_BUTTON_WIDTH, ORDER_BUTTON_HEIGHT)];
[listOrderButton setCenter:CGPointMake(customView.center.x, HEADER_HEIGHT/2)];
[listOrderButton.titleLabel setFont:[UIFont systemFontOfSize:ORDER_BUTTON_FONT_SIZE]];
[listOrderButton.titleLabel setTextAlignment:NSTextAlignmentCenter];
[listOrderButton setTitle:@"ABC" forState:UIControlStateNormal];
[listOrderButton setTitle:@"Time" forState:UIControlStateSelected];
[listOrderButton setTitleColor:[UIColor blueAppColor] forState:UIControlStateNormal];
[listOrderButton addTarget:self action:@selector(listOrderChange:) forControlEvents:UIControlEventTouchUpInside];
[customToolbar addSubview:listOrderButton];

and selector:

- (void)listOrderChange:(UIButton *)sender {
[sender setSelected:!sender.selected];
}

Image of what is happening:

No dot when not selected- There is no point when it is not selected
When selected, there's a dot- If selected, the point

This happens both on the device and in the simulator. Changing the color of the text for any and all states does not affect the color of the point itself.

, - .

+4
1

UIButton , UIBarButton, UIBarButton, UIButton? UITabBar UINavigation Bar, apple UIBarButtonItem bar/tabBar... , UIBarButtonItem ....

0

Source: https://habr.com/ru/post/1541665/


All Articles