UISwitch】的更多相关文章

- (void)viewDidLoad {    [super viewDidLoad];        // 实例化UISwitch,固定大小    UISwitch *swc = [[UISwitch alloc] initWithFrame:CGRectMake(40, 100, 295, 30)];        // 主题颜色    swc.thumbTintColor = [UIColor redColor];    swc.onTintColor = [UIColor orange…
UISwitch *noticeSwtich = [[UISwitch alloc] initWithFrame:CGRectMake(0, 0, 51, 31)]; // noticeSwtich.layer.cornerRadius = noticeSwtich.height/2; // noticeSwtich.backgroundColor = RGB(0, 187, 39); // noticeSwtich.tintColor = RGB(0, 187, 39);//设置关着的时候的颜…
//UIActivityIndicatorView //小菊花,加载 #import "ActivityIndicatorVC.h" @interface ActivityIndicatorVC (){ UIActivityIndicatorView *_activity ; } @end @implementation ActivityIndicatorVC -(void)viewDidLoad{ [super viewDidLoad]; [self createActivityIn…
基础小控件 /***************************************UIlabel*************************************/ UILabel *label = [[UILabel alloc]init];//创建UIlabel对象 label.frame = CGRectMake(50, 50, 100, 50);//设定label的位置与大小 label.backgroundColor = [UIColoryellowColor];//…
UISwitch控件的作用是提供一个开关给用户,用户可以选择打开或者关闭. UISwitch的基本属性包括: 1.onTintColor:打开状态下的背景颜色 2.thumbTintColor:滑块的颜色 UISwitch可以通过UIControlEventValueChanged来达到监听开关状态的变化. ps:onTintColor没有对应的offTintColor属性,你可以通过设置父控件背景色的方式(backgroundColor)来控制关闭状态下的背景色. - (void) creat…
UIImageView——图像视图 作用:专门用来显示图片的控件 . 设置图像 [self.imageView setImage:[UIImage imageNamed:@"abc.png"]]; . 设置显示模式 设置图片居中显示,并且保持原来宽高比 imageView.contentMode = UIViewContentModeScaleAspectFit;…
一.UISwitch 1.初始化 UISwitch *s1 = [[UISwitch alloc]initWithFrame:CGRectMake(50, 170, 100, 200)];   2.设置相关属性 s1.onTintColor = [UIColor blueColor]; s1.tintColor = [UIColor greenColor]; s1.thumbTintColor = [UIColor redColor]; 3.设置开关状态 s1.on = YES; 4.添加事件…
UISwitch属性1. onTintColor   处于on时switch 的颜色
    switchImage.onTintColor = [UIColor grayColor];2.tintColor 处于off时switch 的颜色    switchImage.tintColor = [UIColor greenColor];3.onImage      设置on 的图标
    switchImage.onImage = [UIImage imageNamed:@"1.png&qu…
以下是常用属性: self.mySwitch.layer.cornerRadius = 15;   // 边框圆角角度 self.mySwitch.layer.borderWidth = 2;  // 边框宽度 self.mySwitch.layer.borderColor = [UIColor redColor].CGColor;  // 边框颜色 self.mySwitch.backgroundColor = [UIColor yellowColor];   // 背景颜色 self.myS…
- (void)viewDidLoad{    [super viewDidLoad];    //创建一个开关控件,苹果给它固定的size(79*27),frame更改size无效    //继承于UIControl 为事件驱动型控件    UISwitch *st = [[UISwitch alloc] initWithFrame:CGRectMake(10,10,100,50)];    //on 属性,控制开关的开闭(YES 开)    st.on =YES;    //事件驱动型,通过…
前言 NS_CLASS_AVAILABLE_IOS(2_0) __TVOS_PROHIBITED @interface UISwitch : UIControl <NSCoding> @available(iOS 2.0, *) public class UISwitch : UIControl, NSCoding 1.Switch 的创建 Objective-C // 实例化 switch 对象,switch 的大小是由系统固定的 UISwitch *switch1 = [[UISwitch…
工作之余,学习下swift大法.把自己的学习过程分享一下.当中的布局很乱,就表在意这些细节了.直接上代码: UIButton+UILabel // // ViewController.swift // manyControl // // Created by shaoting on 16/3/23. // Copyright © 2016年 9elephas. All rights reserved. // /// swift控件篇 // UIButton // UILabel import U…
// // ViewController.swift // UILabelTest // // Created by mac on 15/6/23. // Copyright (c) 2015年 fangyuhao. All rights reserved. // import UIKit class ViewController: UIViewController { var uiswitch:UISwitch!; override func viewDidLoad() { super.vie…
UISegmentedControl 分段控件 //1. UISegmentedControl 分段控件 (就是一个一个的按钮) //分段显示的标题是以一个数组存储的 NSArray * titles = @[@"护卫队",@"三军仪仗队",@"步兵队"]; UISegmentedControl * segment = [[UISegmentedControl alloc]initWithItems:titles]; segment.frame…
UISwitch/UIStepper override func viewDidLoad() { super.viewDidLoad() titleLabel.text = titleString // Do any additional setup after loading the view. //创建开关控件 var switchView:UISwitch = UISwitch(frame: CGRectMake(, , , )) //添加到视图上 self.view.addSubview…
UISwitch //开关    不用设置宽高  有默认宽高 UISwitch * sw = [[UISwitch alloc] initWithFrame:CGRectMake(100, 100, 0, 0)]; //开关的状态 sw.on = YES; //开关打开时的颜色 sw.onTintColor = [UIColor redColor]; //开关关闭时的颜色 sw.tintColor = [UIColor cyanColor]; //开关圆圈的颜色 sw.thumbTintColo…
Creating and Using Switches with UISwitch You would like to give your users the ability to turn an option on or off. effect as follow: SolutionUse the UISwitch class. Some steps to implment: 1. Let’s create a property of type UISwitch and call it mai…
UISwitch开关控件 开关代替了点选框.开关是到目前为止用起来最简单的控件,不过仍然可以作一定程度的定制化. 一.创建 UISwitch* mySwitch = [[ UISwitchalloc]initWithFrame:CGRectMake(200.0,10.0,0.0,0.0)]; 是不是很奇怪,大小竟然是0.0×0.0,没错,系统会自动帮你决定最佳的尺寸,你自己写的尺寸会被忽略掉,你只要定义好相对父视图的位置就好了.默认尺寸为79 * 27. 二.显示控件 [ parrentView…
这里解释一个小例子,希望对你有点帮助,利用UISwitch控制UIimage的动画效果 先定义一个数组,用来存放照片,现在定义数组有一个特别简单的方法: NSArray *image1 = @[]; 但是要注意的是,其中插入的是对象. UIImage *img1 = [UIImage imageNamed:@"1.png"]; UIImage *img2 = [UIImage imageNamed:@"2.png"]; UIImage *img3 = [UIImag…
1.UIStepper 步进控件 必掌握 1.重要属性: .value 初始值 .maximumValue 最大值 .minimumValue 最小值 .stepValue 间隔 2.常用事件: ValueChanged事件:当数值改变时触发 2 .UISlider 滑块控件 快速滑动的方式得到一个可变数值 1.重要属性: .value 2.重要事件: ValueChanged事件:当数值改变时触发 //显示滑块控件的初始值 self.sliderLabel.text = [NSString s…
UISwitch *swh = [[UISwitch alloc]initWithFrame:CGRectMake(100,100, 50, 30)];        swh.on = YES;        [swh addTarget:self action:@selector(switchAction:) forControlEvents:UIControlEventValueChanged];        cell.accessoryView = swh;        cell.te…
1.2 UISwitch创建和使用开关 问题你想给你的用户打开一个选项或关闭的能力.解使用UISwitch类. 讨论该UISwitch类提供像在图1-7为自动大写,自动校正,等等所示的开/关控制. 图1-7.UISwitch用在iPhone上的应用程序的设置为了创建一个开关,你可以使用Interface Builder或者干脆在代码中创建的实例.让我们通过代码做到这一点.所以,接下来的挑战是确定放置哪个类的代码,它需要在一个视图控制器类,我们还没有讨论,但对于应用程序的单一视图的应用…
下面演示如何创建开关,以及监听它值的改变,代码如下: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 class ViewController: UIViewController {     var uiswitch:UISwitch!;     override func viewDidLoad() {             super.viewDidLoad()             uiswitch = UISwitch()       …
UISwitch iOS中的开关控件,只有两种状态,打开或关闭. aSwitch.tintColor = [UIColor redColor]; //关闭状态下的渲染颜色 aSwitch.onTintColor = [UIColor blueColor]; //打开状态下的渲染颜色. aSwitch.on = NO; //将其显示状态为打开 (默认关闭). aSwitch.thumbTintColor = [UIColor blackColor]; //改变switch开关按钮的颜色. [aSw…
- (void)viewDidLoad { [super viewDidLoad]; [self buttonswitch]; [self buttonslider]; } -(void)buttonswitch { // UIswitch self.view.backgroundColor = [UIColor whiteColor]; UISwitch *switc = [[UISwitch alloc]init]; switc.frame = CGRectMake(50, 50, 50,…
开关的可配置选项很少,一般用于处理布尔值. 下面给出一个小Demo,创建两个开关,开关一可以控制开关二的可用与否,两者的关系就相当于水闸与水龙头的关系. #import "ViewController.h" @interface ViewController () @property(nonatomic,strong) UISwitch *swicth1; @property(nonatomic,strong) UISwitch *switch2; @end @implementati…
此文学习来源为:http://study.163.com/course/introduction/1002858003.htm 此工程文件实现功能:  1.定义UIswitch控件,添加UIswitch控件属性 2.设置开关的基本属性,如颜色 3.向开关添加事件函数 ===========================ViewController.h脚本============================== #import <UIKit/UIKit.h> @interface View…
博客地址 : http://blog.csdn.net/shulianghan/article/details/50051499 ; 一. UI 控件简介 1. UI 控件分类 UI 控件分类 : 活动控件, 被动控件, 静态控件; -- 活动控件 : 继承了 UIControl 基类, 该类控件可以与用户交互, 对应操作会激发对应的 事件绑定回调方法, 之前的 UIButton 就是这种控件; -- 静态控件 : 继承了 UIView 基类, 该类控件与用户之间不能交互, 之前使用的 UILa…
import UIKit class ViewController: UIViewController { var uiswitch: UISwitch? override func viewDidLoad() { super.viewDidLoad() uiswitch = UISwitch() // 设置位置 (开关无法设置大小) uiswitch?.center = CGPoint(x: 100, y: 50) self.view.addSubview(uiswitch!) // 设置默认…
(1)UISwitch的大小也是固定的,不随我们frame设置的大小改变:也是裁剪成圆角的,设置背景就露马脚发现背景是矩形. (2)UISwitch的背景图片设置无效,即我们只能设置颜色,不能用图片当背景,虽然实验了很小的图片,也是不行.可能需要借助第三方类来实现. (3)UISwitch也可以增加addTarget:方法,来获取值变动的操作,从而做出响应的反应. (4).isOn属性比较特殊,不能设置值,因为是哥getter方法,不是setter方法,所以只能获取值,例如判断是否开启,一般用在…