zoukankan      html  css  js  c++  java
  • 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;

    }

  • 相关阅读:
    排序
    FileOutputStream文件写入 —— 覆盖、追加
    判断一个地图坐标是否在中国镜内
    地图坐标转换
    全文检索 使用最新lucene3.0.3+最新盘古分词 pangu2.4 .net 实例
    blob转base64位 base64位转blob
    div中粘贴图片并上传服务器 div中拖拽图片文件并上传服务器
    DIV 粘贴插入文本或者其他元素后,移动光标到最新处
    project 计划添加编号或 任务分解时为任务添加编号
    修改project任务的默认开始时间
  • 原文地址:https://www.cnblogs.com/1oo1/p/3977744.html
Copyright © 2011-2022 走看看