91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

UI之窗口與視圖

發布時間:2020-07-18 05:00:18 來源:網絡 閱讀:267 作者:hmymy 欄目:開發技術

----------UI窗口于視圖的創建示例----------

在window上創建赤橙黃綠青藍紫七個視圖,互相嵌套,設置定時器,每秒每個視圖隨機變換顏色,并且旋轉,十秒后停止,視圖全部移除。



---AppDelegate.h中聲明視圖和一個計時的變量

@interface AppDelegate : UIResponder <UIApplicationDelegate>

{

    UIView *view1;

    UIView *view2;

    UIView *view3;

    UIView *view4;

    UIView *view5;

    UIView *view6;

    UIView *view7;

    int second;


}

---AppDelegate.m中實現題中要求

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    CGRect rect = [UIScreen mainScreen].bounds;

    //創建主Window

    self.window = [[UIWindow alloc]initWithFrame:rect];

    self.window.backgroundColor = [UIColor blackColor];

    [self.window makeKeyAndVisible];

    

    //創建View

    view1 = [[UIView alloc]initWithFrame:CGRectMake(70, 70, 250, 250)];

    view1.backgroundColor= [UIColor redColor];

    view1.tag = 1;

    

    view2 = [[UIView alloc]initWithFrame:CGRectMake(15, 15, 220, 220)];

    view2.backgroundColor= [UIColor orangeColor];


    view3 = [[UIView alloc]initWithFrame:CGRectMake(15, 15, 190, 190)];

    view3.backgroundColor= [UIColor yellowColor];


    view4 = [[UIView alloc]initWithFrame:CGRectMake(15, 15, 160, 160)];

    view4.backgroundColor= [UIColor greenColor];


    view5 = [[UIView alloc]initWithFrame:CGRectMake(15, 15 , 130, 130)];

    view5.backgroundColor= [UIColor cyanColor];


    view6 = [[UIView alloc]initWithFrame:CGRectMake(15, 15, 100, 100)];

    view6.backgroundColor= [UIColor blueColor];


    view7 = [[UIView alloc]initWithFrame:CGRectMake(25, 25, 50, 50)];

    view7.backgroundColor= [UIColor purpleColor];


    [self.window addSubview:view1];

    [view1 addSubview:view2];

    [view2 addSubview:view3];

    [view3 addSubview:view4];

    [view4 addSubview:view5];

    [view5 addSubview:view6];

    [view6 addSubview:view7];

    

    second = 10;




    //定時器

    [NSTimer scheduledTimerWithTimeInterval:1

                                     target:self

                                   selector:@selector(timeAction:)

                                   userInfo:nil

                                    repeats:YES];

    

    

    

        return YES;

}


- (void)timeAction:(NSTimer *)timer{

    //七個視圖顏色隨機變

    view1.backgroundColor = [UIColor colorWithRed:(arc4random()%255/255.0) green:(arc4random()%255/255.0) blue:(arc4random()%255/255.0) alpha:1];

    view2.backgroundColor = [UIColor colorWithRed:(arc4random()%255/255.0) green:(arc4random()%255/255.0) blue:(arc4random()%255/255.0) alpha:1];

    view3.backgroundColor = [UIColor colorWithRed:(arc4random()%255/255.0) green:(arc4random()%255/255.0) blue:(arc4random()%255/255.0) alpha:1];

    view4.backgroundColor = [UIColor colorWithRed:(arc4random()%255/255.0) green:(arc4random()%255/255.0) blue:(arc4random()%255/255.0) alpha:1];

    view5.backgroundColor = [UIColor colorWithRed:(arc4random()%255/255.0) green:(arc4random()%255/255.0) blue:(arc4random()%255/255.0) alpha:1];

    view6.backgroundColor = [UIColor colorWithRed:(arc4random()%255/255.0) green:(arc4random()%255/255.0) blue:(arc4random()%255/255.0) alpha:1];

    view7.backgroundColor = [UIColor colorWithRed:(arc4random()%255/255.0) green:(arc4random()%255/255.0) blue:(arc4random()%255/255.0) alpha:1];

    

    //旋轉

    UIView *view = [self.window viewWithTag:1];

    CGAffineTransform trans = view.transform;

    view.transform = CGAffineTransformRotate(trans, M_PI/10);


    

    

    //十秒后計時器停止,視圖移除

    second--;

    if (second < 0) {

        [timer invalidate];

        [view1 removeFromSuperview];

        return;

    }

        

}















向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

东平县| 蒙阴县| 益阳市| 新巴尔虎左旗| 长治市| 周宁县| 霍州市| 上饶市| 乌拉特后旗| 东海县| 泽普县| 眉山市| 寿光市| 二连浩特市| 黎川县| 六枝特区| 宜兴市| 巴南区| 拉孜县| 旅游| 寿宁县| 金沙县| 措美县| 和龙市| 神农架林区| 本溪| 红桥区| 涞源县| 繁峙县| 博客| 山阳县| 夏邑县| 汝阳县| 西吉县| 凌源市| 张掖市| 乐安县| 黔东| 婺源县| 饶阳县| 定南县|