OC, oc Language

Source: Internet
Author: User

OC, oc Language
Introduction

  • Each UI control automatically creates a layer (root layer) by default, that is, each UI control corresponds to at least one layer.
  • Each UIView is associated with a CALayer by default. We can call this Layer as the Root Layer)
  • All non-Root layers, I .e. manually created CALayer objects, have implicit animation. What is implicit animation?
  • When some attributes of a non-Root Layer are modified, some animation effects are automatically generated by default.
  • These attributes are called animation Properties)
  • Common Properties of executable implicit Animation

    • Position and size

      • AnchorPoint, anchorPoint
      • Position
      • Bounds, size
      • Frame, position and size
      • Transform, Deformation
    • Appearance

      • BackgroundColor, background color
      • Hidden, whether to hide
      • Opacity, transparency
      • MaskToBounds: whether to cut content beyond the layer area
      • CornerRadius, rounded corner radius
    • Border

      • BorderWidth, Border Width
      • BorderColor, border color
    • Shadow

      • ShadowColor, background color
      • ShadowOffset, background offset
      • ShadowOpacity, background transparency
      • ShadowPath: the path of the background border, that is, the shape of the image that the background displays.
      • ShadowRaduis indicates the radius of the rounded corner of the background.
Example
  • Create a UIView object through storyboard and own the object

    @property (weak, nonatomic) IBOutlet UIView *blueView;
  • Click on the screen to dynamically modify the animation properties of the layer.

    -(Void) touchesBegan :( NSSet *) touches withEvent :( UIEvent *) event {// generate a random rotation angle using a random number CGFloat angle = angleToRadion (arc4random_uniform (360) + 1 ); // rotate self. blueView. layer. transform = CATransform3DMakeRotation (angle, 0, 0, 1); // move to a random position (50 ~ 249, 50 ~ 449) self. blueView. layer. position = CGPointMake (arc4random_uniform (200) + 50, arc4random_uniform (400) + 50); // set the random radius of the rounded corner self. blueView. layer. cornerRadius = arc4random_uniform (50); // set the random background color self. blueView. layer. backgroundColor = [self randomColor]. CGColor; // set the random Border Width self. blueView. layer. borderWidth = arc4random_uniform (10); // set the random border color self. blueView. layer. borderColor = [self randomColor]. CGColor ;}
  • Method for generating random colors

    - (UIColor *)randomColor{return [UIColor colorWithRed:arc4random_uniform(256) / 255.0 green:arc4random_uniform(256) / 255.0 blue:arc4random_uniform(256) / 255.0 alpha:1];}
  • Effect

     

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.