• ios 中的半屏幕底部弹出框


    static UIView *modalView;
    if
    (modalView) { [modalView removeFromSuperview]; modalView = nil; return; } CGRect screen = [[UIScreen mainScreen] bounds]; CGRect bounds = CGRectMake(screen.origin.x, screen.origin.y, screen.size.width, screen.size.height/2); modalView = [[UIView alloc] initWithFrame:bounds]; modalView.opaque = NO; modalView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.5f]; UILabel *label = [[UILabel alloc] init]; label.text = @"Modal View"; label.textColor = [UIColor whiteColor]; label.backgroundColor = [UIColor clearColor]; label.opaque = NO; [label sizeToFit]; [label setCenter:CGPointMake(modalView.frame.size.width / 2, modalView.frame.size.height / 2)]; [modalView addSubview:label]; [self.view addSubview:modalView];

    若要从xib众加载UI的外观,则:

    if (popupViewController) {
            [popupViewController.view removeFromSuperview];
            popupViewController = nil;
            return;
        }
        
        popupViewController = [[UIViewController alloc] initWithNibName:@"View" bundle:nil];
        [self.view addSubview:popupViewController.view];

    如果需要从底部的动画向上slide in的动画:

    UIView *popView = popupViewController.view;
        CGRect orig = popView.bounds;
        CGRect screen = [[UIScreen mainScreen] bounds];
        [popView setFrame:CGRectMake(0, screen.size.height, orig.size.width, orig.size.height)];
        [UIView beginAnimations:@"animatePopView" context:nil];
        [UIView setAnimationDuration:0.4];
        [popView setFrame:CGRectMake(0, screen.size.height-orig.size.height, orig.size.width, orig.size.height)];
        [UIView commitAnimations];

    Add a UIView above all, even the navigation bar

    UIView* myView = /* Your custom view */;
    UIWindow* currentWindow = [UIApplication sharedApplication].keyWindow;
    [currentWindow addSubview:myView];

    或者:

    [self.navigationController.view addSubview:overlayView];
  • 相关阅读:
    网络流24题总结和题解
    NOIP复习之1 数学数论
    BZOJ3301 P2524 UVA11525 算法解释康托展开
    线段树与树状数组的综合运用
    P2261 bzoj1257 [CQOI2007]余数求和
    BZOJ 1968_P1403 [AHOI2005]约数研究--p2260bzoj2956-模积和∑----信息学中的数论分块
    P1064 金明的预算方案
    洛谷p1002 过河卒
    Luogu P3014 [USACO11FEB]牛线Cow Line
    Luogu P3927 SAC E#1
  • 原文地址:https://www.cnblogs.com/welhzh/p/4318756.html
Copyright © 2020-2023  润新知