zoukankan      html  css  js  c++  java
  • Swift UILabel的使用

    1.新建Swift IOS app空项目





    加入代码

    //
    //  AppDelegate.swift
    //  UILableDemo
    //
    //  Created by 赵超 on 14-6-17.
    //  Copyright (c) 2014年 赵超. All rights reserved.
    //
    
    import UIKit
    
    @UIApplicationMain
    class AppDelegate: UIResponder, UIApplicationDelegate {
        
        var window: UIWindow?
        var label:UILabel?
    
        func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool {
            self.window = UIWindow(frame: UIScreen.mainScreen().bounds)
            // Override point for customization after application launch.
            self.window!.backgroundColor = UIColor.grayColor()
            self.window!.makeKeyAndVisible()
            //初始化UILabel
            label=UILabel()
            //label大小
            label!.frame = CGRect(x:50, y:100, 200, height:100)
            label!.text = "Hello Swift"
            //背影色
            label!.backgroundColor=UIColor.blueColor()
            //对齐
            label!.textAlignment=NSTextAlignment.Center
            //字体
            label!.font=UIFont(name:"Thonburi",size:30)
            //Gray
            var labColor=UIColor(white:1,alpha:1);
            //RGB
            labColor=UIColor(red:255,green:255,blue:0,alpha:1)
            //系统色
            labColor=UIColor.lightTextColor()
            //静态色
            labColor=UIColor.redColor();
            label!.textColor=labColor
            
            self.window!.addSubview(label)
            return true
        }
    
        func applicationWillResignActive(application: UIApplication) {
            // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
            // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
        }
    
        func applicationDidEnterBackground(application: UIApplication) {
            // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
            // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
        }
    
        func applicationWillEnterForeground(application: UIApplication) {
            // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
        }
    
        func applicationDidBecomeActive(application: UIApplication) {
            // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
        }
    
        func applicationWillTerminate(application: UIApplication) {
            // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
        }
    
    
    }
    

    效果图



  • 相关阅读:
    几个不同的关键XPath概念
    go get 下载的包放在哪里呢?
    之前写的关于chromedp的文章被别人转到CSDN,很受鼓励,再来一篇golang爬虫实例
    微信小程序填坑之旅(2)-wx.showLoading的时候,仍能点击穿透,造成重复点击button的问题
    微信小程序填坑之旅(1)-app.js中用云开发获取openid,在其他页上用app.globaldata.openid获取为空
    JS 定时器-setInterval、clearInterval、setTimeout
    微信小程序开发入门教程(四)---自己动手做个小程序
    MT【247】恒成立画图像
    MT【246】方程根$acksim$图像交点
    MT【245】小概率事件
  • 原文地址:https://www.cnblogs.com/whzhaochao/p/5023450.html
Copyright © 2011-2022 走看看