悬浮按钮

@property(strong,nonatomic)UIWindow *window;

@property(strong,nonatomic)UIButton *FloatBtn;

 

   _FloatBtn = [UIButton buttonWithType:UIButtonTypeCustom];

    [_FloatBtn setTitle:@"发布需求" forState:UIControlStateNormal];

    _FloatBtn.titleLabel.font = [UIFont fontWithName:@"Arial" size:12];

    _FloatBtn.frame = CGRectMake(0, 0, 60, 60);

    [_FloatBtn addTarget:self action:@selector(resignWindow) forControlEvents:UIControlEventTouchUpInside];

    

    _window = [[UIWindow alloc]initWithFrame:CGRectMake(SCREENWIDTH-90, SCREENHEIGHT-100, 60, 60)];

    _window.windowLevel = UIWindowLevelAlert+1;

    _window.backgroundColor = [UIColor colorwithHexString:@"#9d8a84"];

    _window.layer.borderWidth = 0.2;

    _window.layer.borderColor=[UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:0.6].CGColor;

    //阴影的颜色

    _window.layer.shadowColor = [[UIColor blackColor] CGColor];

    _window.layer.shadowOffset = CGSizeMake(3, 3);

//

////    _window.layer.backgroundColor=[UIColor blackColor].CGColor;

    _window.layer.shadowColor=[UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:0.6].CGColor;

    _window.layer.shadowRadius=5;

////    _window.layer.shadowOffset=CGSizeMake(1, 1);

    _window.layer.shadowOpacity=0.3;

    

    _window.layer.cornerRadius = 30;

    _window.layer.masksToBounds = YES;

    [_window addSubview:_FloatBtn];

    [_window makeKeyAndVisible];//关键语句,显示window

 

/**

 *  关闭悬浮的window

 */

- (void)resignWindow

{

    

    [_window resignKeyWindow];

    [_window setHidden:YES];

    _window = nil;

    //跳转页面

    DistrubuteViewController *dis = [[DistrubuteViewController alloc]init];

    [self.navigationController pushViewController:dis animated:YES];

    

}

posted on 2016-05-12 16:55  廖利君  阅读(228)  评论(0编辑  收藏  举报