swift UIProgressView UISilder UISwitch使用

2024-05-31 06:32

本文主要是介绍swift UIProgressView UISilder UISwitch使用,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

代码

[objc]  view plain copy 在CODE上查看代码片 派生到我的代码片
  1. //  
  2. //  AppDelegate.swift  
  3. //  UIPrograssViewDemo  
  4. //  
  5. //  Created by 赵超 on 14-6-18.  
  6. //  Copyright (c) 2014年 赵超. All rights reserved.  
  7. //  
  8.   
  9. import UIKit  
  10.   
  11. @UIApplicationMain  
  12. class AppDelegate: UIResponder, UIApplicationDelegate {  
  13.                               
  14.     var window: UIWindow?  
  15.     var progressView:UIProgressView!  
  16.     var slider:UISlider!  
  17.     var uiSwitch:UISwitch!  
  18.       
  19.     func sliderChange(){  
  20.         println(self.slider.value)  
  21.     }  
  22.     func switchchange(){  
  23.         println(self.uiSwitch.on)  
  24.     }  
  25.   
  26.     func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: NSDictionary?) -> Bool {  
  27.         self.window = UIWindow(frame: UIScreen.mainScreen().bounds)  
  28.         // Override point for customization after application launch.  
  29.         self.window!.backgroundColor = UIColor.whiteColor()  
  30.         self.window!.makeKeyAndVisible()  
  31.           
  32.         self.progressView=UIProgressView(progressViewStyle : UIProgressViewStyle.Default)  
  33.         self.progressView.frame=CGRectMake(10,40,300,100)  
  34.           
  35.         self.progressView.progress=0.5  
  36.           
  37.         self.progressView.progressTintColor=UIColor.blueColor()  
  38.           
  39.         self.progressView.trackTintColor=UIColor.greenColor()  
  40.           
  41.         self.progressView.backgroundColor=UIColor.redColor()  
  42.         //UISlider  
  43.         self.slider=UISlider()  
  44.         self.slider.frame=CGRectMake(10,200,300,100)  
  45.         self.slider.backgroundColor=UIColor.redColor()  
  46.         self.slider.minimumValue=0  
  47.         self.slider.maximumValue=100  
  48.         self.slider.value=50  
  49.         self.slider.addTarget(self,action:Selector("sliderChange"), forControlEvents: UIControlEvents.ValueChanged)  
  50.   
  51.           
  52.         self.uiSwitch=UISwitch(frame:CGRectMake(40,400,300,100))  
  53.       //  self.uiSwitch.backgroundColor=UIColor.redColor()  
  54.         self.uiSwitch.addTarget(self,action:Selector("switchchange"), forControlEvents: UIControlEvents.ValueChanged)  
  55.   
  56.         self.window!.addSubview(self.uiSwitch)  
  57.         self.window!.addSubview(self.slider)  
  58.         self.window!.addSubview(self.progressView)  
  59.           
  60.         return true  
  61.     }  
  62.   
  63.     func applicationWillResignActive(application: UIApplication) {  
  64.         // 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.  
  65.         // 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.  
  66.     }  
  67.   
  68.     func applicationDidEnterBackground(application: UIApplication) {  
  69.         // 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.  
  70.         // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.  
  71.     }  
  72.   
  73.     func applicationWillEnterForeground(application: UIApplication) {  
  74.         // 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.  
  75.     }  
  76.   
  77.     func applicationDidBecomeActive(application: UIApplication) {  
  78.         // 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.  
  79.     }  
  80.   
  81.     func applicationWillTerminate(application: UIApplication) {  
  82.         // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.  
  83.     }  
  84.   
  85.   
  86. }  


这篇关于swift UIProgressView UISilder UISwitch使用的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1017507

相关文章

Java中的ConcurrentBitSet使用小结

《Java中的ConcurrentBitSet使用小结》本文主要介绍了Java中的ConcurrentBitSet使用小结,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,... 目录一、核心澄清:Java标准库无内置ConcurrentBitSet二、推荐方案:Eclipse

Go语言结构体标签(Tag)的使用小结

《Go语言结构体标签(Tag)的使用小结》结构体标签Tag是Go语言中附加在结构体字段后的元数据字符串,用于提供额外的属性信息,这些信息可以通过反射在运行时读取和解析,下面就来详细的介绍一下Tag的使... 目录什么是结构体标签?基本语法常见的标签用途1.jsON 序列化/反序列化(最常用)2.数据库操作(

Java中ScopeValue的使用小结

《Java中ScopeValue的使用小结》Java21引入的ScopedValue是一种作用域内共享不可变数据的预览API,本文就来详细介绍一下Java中ScopeValue的使用小结,感兴趣的可以... 目录一、Java ScopedValue(作用域值)详解1. 定义与背景2. 核心特性3. 使用方法

spring中Interceptor的使用小结

《spring中Interceptor的使用小结》SpringInterceptor是SpringMVC提供的一种机制,用于在请求处理的不同阶段插入自定义逻辑,通过实现HandlerIntercept... 目录一、Interceptor 的核心概念二、Interceptor 的创建与配置三、拦截器的执行顺

C#中checked关键字的使用小结

《C#中checked关键字的使用小结》本文主要介绍了C#中checked关键字的使用,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学... 目录✅ 为什么需要checked? 问题:整数溢出是“静默China编程”的(默认)checked的三种用

C#中预处理器指令的使用小结

《C#中预处理器指令的使用小结》本文主要介绍了C#中预处理器指令的使用,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧... 目录 第 1 名:#if/#else/#elif/#endif✅用途:条件编译(绝对最常用!) 典型场景: 示例

Mysql中RelayLog中继日志的使用

《Mysql中RelayLog中继日志的使用》MySQLRelayLog中继日志是主从复制架构中的核心组件,负责将从主库获取的Binlog事件暂存并应用到从库,本文就来详细的介绍一下RelayLog中... 目录一、什么是 Relay Log(中继日志)二、Relay Log 的工作流程三、Relay Lo

使用Redis实现会话管理的示例代码

《使用Redis实现会话管理的示例代码》文章介绍了如何使用Redis实现会话管理,包括会话的创建、读取、更新和删除操作,通过设置会话超时时间并重置,可以确保会话在用户持续活动期间不会过期,此外,展示了... 目录1. 会话管理的基本概念2. 使用Redis实现会话管理2.1 引入依赖2.2 会话管理基本操作

Springboot请求和响应相关注解及使用场景分析

《Springboot请求和响应相关注解及使用场景分析》本文介绍了SpringBoot中用于处理HTTP请求和构建HTTP响应的常用注解,包括@RequestMapping、@RequestParam... 目录1. 请求处理注解@RequestMapping@GetMapping, @PostMappin

springboot3.x使用@NacosValue无法获取配置信息的解决过程

《springboot3.x使用@NacosValue无法获取配置信息的解决过程》在SpringBoot3.x中升级Nacos依赖后,使用@NacosValue无法动态获取配置,通过引入SpringC... 目录一、python问题描述二、解决方案总结一、问题描述springboot从2android.x