在屏幕特定位置点击隐藏子窗口

来源:互联网 发布:菜鸟数据分析 编辑:程序博客网 时间:2024/05/22 14:08
#import "ViewController.h"#import "MusicListView.h"@interface ViewController ()// 列表子窗口@property (nonatomic, strong) MusicListView* listView;// 进度条控件@property (strong, nonatomic) IBOutlet UIImageView *progressImageView;@end@implementation ViewController- (void)viewDidLoad {    [super viewDidLoad];    // Do any additional setup after loading the view, typically from a nib.    
    // other codes
    // ...}
// other codes
// ...
#pragma mark --TOUCH事件// 触摸事件-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{    UITouch *touch = [touches anyObject];        // 获取触摸点    CGPoint clickPoint = [touch locationInView:self.view];        // 判断是否需要隐藏:只有当列表子窗口处于显示状态才处理隐藏    if (_listView.alpha == 1)    {        // 只有在特定位置或区域才处理触摸事件        if (clickPoint.y < _progressImageView.frame.origin.y)        {            _listView.alpha = 0;        }    }}@end

0 0
原创粉丝点击