标签:
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];
标签:
原文地址:http://www.cnblogs.com/arenouba/p/5183582.html