Chapter 7 Delegation and Text Input

Chapter 7  Delegation and Text Input

1. Applications can access the same technology that powers those effects by using the UIInterpolatingMotionEffect class.

UILabel *label = [[UILabel alloc] init];

UIInterpolatingMotionEffect *motionEffect;

motionEffect = [[UIInterpolatingMotionEffect alloc] initWithKeyPath:@"center.x" type:UIInterpolatingMotionEffectTypeTiltAlongHorizontalAxis];

motionEffect.minimumRelativeValue = @(-25);

motionEffect.maximumRelativeValue = @(25);

[label addMotionEffect:motionEffect];

motionEffect = [[UIInterpolatingMotionEffect alloc] initWithKeyPath:@"center.y" type:UIInterpolatingMotionEffectTypeTiltAlongVerticalAxis];

motionEffect.minimumRelativeValue = @(-25);

motionEffect.maximumRelativeValue = @(25);

[label addMotionEffect:motionEffect];

2. To set up the scroll view, you will need to give it one view as a subview and turn off the paging(default NO). The scroll view also needs limits on how much it can zoom in and out. Finally, you need to implement the scroll view delegate method viewForZoomingInScrollView: to return the zoomed view.

-(void)loadView

{

// Create a view

BNRHypnosisView *backgroundView = [[BNRHypnosisView alloc] init];

backgroundView.frame = [UIScreen mainScreen].bounds;

CGRect textFieldRect = CGRectMake(40, 70, 240, 30);

UITextField *textField = [[UITextField alloc] initWithFrame:textFieldRect];

// Setting the border style on the text field will allow us to see it more easily

textField.borderStyle = UITextBorderStyleRoundedRect;

textField.returnKeyType = UIReturnKeyDone;

textField.placeholder = @"Hypnotize me";

textField.delegate = self;

[backgroundView addSubview:textField];

// Scroll view to pinch the view

UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:[UIScreen mainScreen].bounds];

scrollView.delegate = self;

scrollView.minimumZoomScale = .5;

scrollView.maximumZoomScale = 1.5;

scrollView.contentSize = CGSizeMake(300, 200);

zoomView = backgroundView;

[scrollView addSubview:backgroundView];

// Set it as the view of this view controller

self.view = scrollView;

}

// UIScrollView delegate

-(UIView*)viewForZoomingInScrollView:(UIScrollView *)scrollView

{

return zoomView;

}

时间: 2024-08-08 05:34:59

Chapter 7 Delegation and Text Input的相关文章

iOS programming Delegation and Text Input

iOS programming Delegation and Text Input? 1.1 Text Fields? ? CGRect textFieldRect = CGRectMake(40, 70, 240, 30);UITextField *textField = [[UITextField alloc] initWithFrame:textFieldRect]; // Setting the border style on the text field will allow us t

再谈multistage text input(中文输入法)下UITextView的内容长度限制

之前写过一篇<如何更好地限制一个UITextField的输入长度>,在文章最后得到的结论是可以直接使用 UIKIT_EXTERN NSString *const UITextFieldTextDidChangeNotification; 进行监听,截断超出maxLength的部分. 所以后来我在处理UITextView的内容长度时,也直接参考这个方法: [[NSNotificationCenter defaultCenter] addObserver:self selector:@select

Text input(文本输入框)

Text input(文本输入框)是用来获得用户输入的绝佳方式. 你可以用如下方法创建: <input type="text"> 注意,input元素是自关闭的.

谈论multistage text input(中国输入法)下一个UITextView内容长度的限制

我以前写<如何更好地限制UITextField输入长度>.接使用 UIKIT_EXTERN NSString *const UITextFieldTextDidChangeNotification; 进行监听.截断超出maxLength的部分. 所以后来我在处理UITextView的内容长度时,也直接參考这种方法: [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textViewDidChang

Libgdx学习笔记:Simple text input

官方Wiki:https://github.com/libgdx/libgdx/wiki/Simple-text-input 实现接口TextInputListener public class MyTextInputListener implements TextInputListener {       @Override    public void input (String text) {    }       @Override    public void canceled () 

2.Text input and output

文本的输入和输出 输出 要在屏幕上输出文本你需要这样一行代码: print("Hello World") 如果输出多行,要添加符号“\n”: print("Hello World\nThis is a message") 输出值的话: x = 3 print(x) 输出多行数值: x = 2 y = 3 print(x, ' ', y) 输入 得到一个文本值(字符?): name = input("Enter a name: ") 得到一个整数:

给 input 中 type=&quot;text&quot; 设置CSS样式

input[type="text"], input[type="password"] {    border: 1px solid #ccc;    padding: 2px;    font-size: 1.2em;    color: #444;    width: 200px;}

input button和text在不同浏览器中的默认样式

button的width和height和标准的盒模型不一致,是指的包含边框在内的宽度和长度 测试代码: <!DOCTYPE html> <html> <body> <input id="box" type="text"></input> <input type="button" value="按钮"></input> </body>

apple Safari input text 的兼容问题

apple -webkit-tap-highlight-color 这个属性只用于iOS (iPhone和iPad).当你点击一个链接或者通过Javascript定义的可点击元素的时候,它就会出现一个半透明的灰色背景.要重设这个表现,你可以设置-webkit-tap-highlight-color为任何颜色. 想要禁用这个高亮,设置颜色的alpha值为0即可. 示例 屏蔽ios和android下点击元素时出现的阴影 1 -webkit-tap-highlight-color: rgba(255,