zoukankan      html  css  js  c++  java
  • UITouch手指滑动屏幕,屏幕跟着移动

    1.//当手指在屏幕上滑动时

    - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{

    UITouch *touch  = [touches anyObject];

    CGPoint previousPoint = [touch previousLocationInView:self];

    CGPoint currentPoint = [touch locationInView:self];

    CGPoint newCenter = CGPointMake(0,0);

    newCenter.x = self.center.x + (currentPoint.x - previousPoint.x);

    newCenter.y = self.center.y + (currentPoint.y - previousPoint.y);

    self.center = newCenter;

    }

    2.按钮的点击状态,点击一下不返回初始状态的情景

    1)先设置按钮两个状态下的背景图片

    button setImage:[[UIImage ImageNamed:"1.png"] forState:UIControlStateNormal];

    button setImage:[[UIImage ImageNamed:"2.png"] forState:UIControlStateSelected];

    [button addTarget:self action:@selector(click:) forControlEvent:UIControlEventTouchUpInSide];

    2)实现点击方法

    - (void)click {

    button.selected = !button.selected;

    }

    2.加法计算器的实现重要步骤

    1)将输入框的值强转为int类型的,然后将两个输入框的值的和强转为字符串类型的

    label.text = [NSString stringWithFormat:@"%d",sum];

  • 相关阅读:
    Linux命令
    Linux目录说明
    python推导式
    python公共方法
    python集合
    python字典
    python元组
    python列表
    python字符串常用操作方法
    C语言编译过程
  • 原文地址:https://www.cnblogs.com/arenouba/p/5183582.html
Copyright © 2011-2022 走看看