我有一个Tab栏应用程序.在其中一个标签栏中,我有一个导航控制器.我试图设置一个UIButton与图像作为导航栏的右键.
UIButton *refreshButton = [[UIButton alloc] init];
[refreshButton setImage:[UIImage imageNamed:@"refresh_icon.png"] forState:UIControlStateNormal];
[refreshButton addTarget:self action:@selector(refreshSection) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithCustomView:refreshButton];
//[rightButton setImage:[UIImage imageNamed:@"refresh_icon.png"]]; << DOESN'T WORK EITHER
self.navigationItem.rightBarButtonItem = rightButton;
[refreshButton release];
[rightButton release];
Run Code Online (Sandbox Code Playgroud)
但图像没有显示出来.我得到一个隐形按钮.
编辑: 我希望按钮样式为普通或背景为透明,以便只显示图像.因此我使用UI按钮而不是直接使用UIBarButton.
是否可以从UISwipeGestureRecognizer获取手势起点.喜欢它的可能性
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch * touch = [touches anyObject];
gestureStartPoint = [touch locationInView:self];
}
Run Code Online (Sandbox Code Playgroud)