码迷,mamicode.com
首页 > 其他好文 > 详细

悬浮按钮

时间:2016-05-13 10:37:40      阅读:548      评论:0      收藏:0      [点我收藏+]

标签:

@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];

    

}

悬浮按钮

标签:

原文地址:http://www.cnblogs.com/liaolijun/p/5486359.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!