{"rsdb":{"rid":"387395","subhead":"","postdate":"0","aid":"269884","fid":"99","uid":"1","topic":"1","content":"
\n

 <\/p> \n

\n
\n \"\"\n <\/div> \n <\/div> \n

1. \u56fe\u5c42\u6811<\/h1> \n

\u56fe\u5c42\u7684\u6811\u72b6\u7ed3\u6784<\/h3> \n
\n

\u5de8\u5996\u6709\u56fe\u5c42\uff0c\u6d0b\u8471\u4e5f\u6709\u56fe\u5c42\uff0c\u4f60\u6709\u5417\uff1f\u6211\u4eec\u90fd\u6709\u56fe\u5c42 -- \u53f2\u83b1\u514b<\/p> \n <\/blockquote> \n

Core Animation\u5176\u5b9e\u662f\u4e00\u4e2a\u4ee4\u4eba\u8bef\u89e3\u7684\u547d\u540d\u3002\u4f60\u53ef\u80fd\u8ba4\u4e3a\u5b83\u53ea\u662f\u7528\u6765\u505a\u52a8\u753b\u7684\uff0c\u4f46\u5b9e\u9645\u4e0a\u5b83\u662f\u4ece\u4e00\u4e2a\u53eb\u505aLayer Kit\u8fd9\u4e48\u4e00\u4e2a\u4e0d\u600e\u4e48\u548c\u52a8\u753b\u6709\u5173\u7684\u540d\u5b57\u6f14\u53d8\u800c\u6765\uff0c\u6240\u4ee5\u505a\u52a8\u753b\u8fd9\u53ea\u662fCore Animation\u7279\u6027\u7684\u51b0\u5c71\u4e00\u89d2\u3002<\/p> \n

Core Animation\u662f\u4e00\u4e2a\u590d\u5408\u5f15\u64ce\uff0c\u5b83\u7684\u804c\u8d23\u5c31\u662f\u5c3d\u53ef\u80fd\u5feb\u5730\u7ec4\u5408\u5c4f\u5e55\u4e0a\u4e0d\u540c\u7684\u53ef\u89c6\u5185\u5bb9\uff0c\u8fd9\u4e2a\u5185\u5bb9\u662f\u88ab\u5206\u89e3\u6210\u72ec\u7acb\u7684\u56fe\u5c42\uff0c\u5b58\u50a8\u5728\u4e00\u4e2a\u53eb\u505a\u56fe\u5c42\u6811\u7684\u4f53\u7cfb\u4e4b\u4e2d\u3002\u4e8e\u662f\u8fd9\u4e2a\u6811\u5f62\u6210\u4e86UIKit\u4ee5\u53ca\u5728iOS\u5e94\u7528\u7a0b\u5e8f\u5f53\u4e2d\u4f60\u6240\u80fd\u5728\u5c4f\u5e55\u4e0a\u770b\u89c1\u7684\u4e00\u5207\u7684\u57fa\u7840\u3002<\/p> \n

\u5728\u6211\u4eec\u8ba8\u8bba\u52a8\u753b\u4e4b\u524d\uff0c\u6211\u4eec\u5c06\u4ece\u56fe\u5c42\u6811\u5f00\u59cb\uff0c\u6d89\u53ca\u4e00\u4e0bCore Animation\u7684\u9759\u6001\u7ec4\u5408\u4ee5\u53ca\u5e03\u5c40\u7279\u6027\u3002<\/p> \n

1.1 \u56fe\u5c42\u4e0e\u89c6\u56fe<\/h2> \n

\u56fe\u5c42\u4e0e\u89c6\u56fe<\/h3> \n

\u5982\u679c\u4f60\u66fe\u7ecf\u5728iOS\u6216\u8005Mac OS\u5e73\u53f0\u4e0a\u5199\u8fc7\u5e94\u7528\u7a0b\u5e8f\uff0c\u4f60\u53ef\u80fd\u4f1a\u5bf9\u89c6\u56fe\u7684\u6982\u5ff5\u6bd4\u8f83\u719f\u6089\u3002\u4e00\u4e2a\u89c6\u56fe\u5c31\u662f\u5728\u5c4f\u5e55\u4e0a\u663e\u793a\u7684\u4e00\u4e2a\u77e9\u5f62\u5757\uff08\u6bd4\u5982\u56fe\u7247\uff0c\u6587\u5b57\u6216\u8005\u89c6\u9891\uff09\uff0c\u5b83\u80fd\u591f\u62e6\u622a\u7c7b\u4f3c\u4e8e\u9f20\u6807\u70b9\u51fb\u6216\u8005\u89e6\u6478\u624b\u52bf\u7b49\u7528\u6237\u8f93\u5165\u3002\u89c6\u56fe\u5728\u5c42\u7ea7\u5173\u7cfb\u4e2d\u53ef\u4ee5\u4e92\u76f8\u5d4c\u5957\uff0c\u4e00\u4e2a\u89c6\u56fe\u53ef\u4ee5\u7ba1\u7406\u5b83\u7684\u6240\u6709\u5b50\u89c6\u56fe\u7684\u4f4d\u7f6e\u3002\u56fe1.1\u663e\u793a\u4e86\u4e00\u79cd\u5178\u578b\u7684\u89c6\u56fe\u5c42\u7ea7\u5173\u7cfb<\/p> \n

1.2 \u56fe\u5c42\u7684\u80fd\u529b<\/h2> \n

\u56fe\u5c42\u7684\u80fd\u529b<\/h3> \n

\u5982\u679c\u8bf4CALayer<\/code>\u662fUIView\u5185\u90e8\u5b9e\u73b0\u7ec6\u8282\uff0c\u90a3\u6211\u4eec\u4e3a\u4ec0\u4e48\u8981\u5168\u9762\u5730\u4e86\u89e3\u5b83\u5462\uff1f\u82f9\u679c\u5f53\u7136\u4e3a\u6211\u4eec\u63d0\u4f9b\u4e86\u4f18\u7f8e\u7b80\u6d01\u7684UIView<\/code>\u63a5\u53e3\uff0c\u90a3\u4e48\u6211\u4eec\u662f\u5426\u5c31\u6ca1\u5fc5\u8981\u76f4\u63a5\u53bb\u5904\u7406Core Animation\u7684\u7ec6\u8282\u4e86\u5462\uff1f<\/p> \n

\u67d0\u79cd\u610f\u4e49\u4e0a\u8bf4\u7684\u786e\u662f\u8fd9\u6837\uff0c\u5bf9\u4e00\u4e9b\u7b80\u5355\u7684\u9700\u6c42\u6765\u8bf4\uff0c\u6211\u4eec\u786e\u5b9e\u6ca1\u5fc5\u8981\u5904\u7406CALayer<\/code>\uff0c\u56e0\u4e3a\u82f9\u679c\u5df2\u7ecf\u901a\u8fc7UIView<\/code>\u7684\u9ad8\u7ea7API\u95f4\u63a5\u5730\u4f7f\u5f97\u52a8\u753b\u53d8\u5f97\u5f88\u7b80\u5355\u3002<\/p> \n

\u4f46\u662f\u8fd9\u79cd\u7b80\u5355\u4f1a\u4e0d\u53ef\u907f\u514d\u5730\u5e26\u6765\u4e00\u4e9b\u7075\u6d3b\u4e0a\u7684\u7f3a\u9677\u3002\u5982\u679c\u4f60\u7565\u5fae\u60f3\u5728\u5e95\u5c42\u505a\u4e00\u4e9b\u6539\u53d8\uff0c\u6216\u8005\u4f7f\u7528\u4e00\u4e9b\u82f9\u679c\u6ca1\u6709\u5728UIView<\/code>\u4e0a\u5b9e\u73b0\u7684\u63a5\u53e3\u529f\u80fd\uff0c\u8fd9\u65f6\u9664\u4e86\u4ecb\u5165Core Animation\u5e95\u5c42\u4e4b\u5916\u522b\u65e0\u9009\u62e9\u3002<\/p> \n

\u6211\u4eec\u5df2\u7ecf\u8bc1\u5b9e\u4e86\u56fe\u5c42\u4e0d\u80fd\u50cf\u89c6\u56fe\u90a3\u6837\u5904\u7406\u89e6\u6478\u4e8b\u4ef6\uff0c\u90a3\u4e48\u4ed6\u80fd\u505a\u54ea\u4e9b\u89c6\u56fe\u4e0d\u80fd\u505a\u7684\u5462\uff1f\u8fd9\u91cc\u6709\u4e00\u4e9bUIView\u6ca1\u6709\u66b4\u9732\u51fa\u6765\u7684CALayer<\/code>\u7684\u529f\u80fd\uff1a<\/p> \n

    \n
  • \u9634\u5f71\uff0c\u5706\u89d2\uff0c\u5e26\u989c\u8272\u7684\u8fb9\u6846<\/li> \n
  • 3D\u53d8\u6362<\/li> \n
  • \u975e\u77e9\u5f62\u8303\u56f4<\/li> \n
  • \u900f\u660e\u906e\u7f69<\/li> \n
  • \u591a\u7ea7\u975e\u7ebf\u6027\u52a8\u753b<\/li> \n <\/ul> \n

    \u6211\u4eec\u5c06\u4f1a\u5728\u540e\u7eed\u7ae0\u8282\u4e2d\u63a2\u7d22\u8fd9\u4e9b\u529f\u80fd\uff0c\u9996\u5148\u6211\u4eec\u8981\u5173\u6ce8\u4e00\u4e0b\u5728\u5e94\u7528\u7a0b\u5e8f\u5f53\u4e2dCALayer<\/code>\u662f\u600e\u6837\u88ab\u5229\u7528\u8d77\u6765\u7684\u3002<\/p> \n

    1.3 \u4f7f\u7528\u56fe\u5c42<\/h2> \n

    \u4f7f\u7528\u56fe\u5c42<\/h3> \n

    \u9996\u5148\u6211\u4eec\u6765\u521b\u5efa\u4e00\u4e2a\u7b80\u5355\u7684\u9879\u76ee\uff0c\u6765\u64cd\u7eb5\u4e00\u4e9blayer\u7684\u5c5e\u6027\u3002\u6253\u5f00Xcode\uff0c\u4f7f\u7528Single View Application\u6a21\u677f\u521b\u5efa\u4e00\u4e2a\u5de5\u7a0b\u3002<\/p> \n

    \u5728\u5c4f\u5e55\u4e2d\u592e\u521b\u5efa\u4e00\u4e2a\u5c0f\u89c6\u56fe\uff08\u5927\u7ea6200 X 200\u7684\u5c3a\u5bf8\uff09\uff0c\u5f53\u7136\u4f60\u53ef\u4ee5\u624b\u5de5\u7f16\u7801\uff0c\u6216\u8005\u4f7f\u7528Interface Builder\uff08\u968f\u4f60\u65b9\u4fbf\uff09\u3002\u786e\u4fdd\u4f60\u7684\u89c6\u56fe\u63a7\u5236\u5668\u8981\u6dfb\u52a0\u4e00\u4e2a\u89c6\u56fe\u7684\u5c5e\u6027\u4ee5\u4fbf\u53ef\u4ee5\u76f4\u63a5\u8bbf\u95ee\u5b83\u3002\u6211\u4eec\u628a\u5b83\u79f0\u4f5clayerView\u3002<\/p> \n

    \u8fd0\u884c\u9879\u76ee\uff0c\u5e94\u8be5\u80fd\u5728\u6d45\u7070\u8272\u5c4f\u5e55\u80cc\u666f\u4e2d\u770b\u89c1\u4e00\u4e2a\u767d\u8272\u65b9\u5757\uff0c\u5982\u679c\u6ca1\u770b\u89c1\uff0c\u53ef\u80fd\u9700\u8981\u8c03\u6574\u4e00\u4e0b\u80cc\u666fwindow\u6216\u8005view\u7684\u989c\u8272<\/p> \n

    \u4e4b\u540e\u5c31\u53ef\u4ee5\u5728\u4ee3\u7801\u4e2d\u76f4\u63a5\u5f15\u7528CALayer\u7684\u5c5e\u6027\u548c\u65b9\u6cd5\u3002\u5728\u6e05\u53551.1\u4e2d\uff0c\u6211\u4eec\u7528\u521b\u5efa\u4e86\u4e00\u4e2aCALayer\uff0c\u8bbe\u7f6e\u4e86\u5b83\u7684backgroundColor\u5c5e\u6027\uff0c\u7136\u540e\u6dfb\u52a0\u5230layerView\u80cc\u540e\u76f8\u5173\u56fe\u5c42\u7684\u5b50\u56fe\u5c42\uff08\u8fd9\u6bb5\u4ee3\u7801\u7684\u524d\u63d0\u662f\u901a\u8fc7IB\u521b\u5efa\u4e86layerView\u5e76\u505a\u597d\u4e86\u8fde\u63a5\uff09\uff0c\u56fe1.5\u663e\u793a\u4e86\u7ed3\u679c\u3002<\/p> \n

    \u4e00\u4e2a\u5f00\u53d1\u8005\uff0c\u6709\u4e00\u4e2a\u5b66\u4e60\u7684\u6c1b\u56f4\u8ddf\u4e00\u4e2a\u4ea4\u6d41\u5708\u5b50\u7279\u522b\u91cd\u8981\uff0c\u8fd9\u662f\u4e00\u4e2a\u6211\u7684iOS\u4ea4\u6d41\u7fa4\uff1a1012951431<\/strong>\uff0c \u5206\u4eabBAT,\u963f\u91cc\u9762\u8bd5\u9898\u3001\u9762\u8bd5\u7ecf\u9a8c\uff0c\u8ba8\u8bba\u6280\u672f\uff0c \u5927\u5bb6\u4e00\u8d77\u4ea4\u6d41\u5b66\u4e60\u6210\u957f\uff01\u5e0c\u671b\u5e2e\u52a9\u5f00\u53d1\u8005\u5c11\u8d70\u5f2f\u8def\u3002<\/p> \n

    \u6e05\u53551.1 \u7ed9\u89c6\u56fe\u6dfb\u52a0\u4e00\u4e2a\u84dd\u8272\u5b50\u56fe\u5c42<\/p> \n

    \n
    #import "<\/span>ViewController.h<\/span>"<\/span>\n#import \n@interface ViewController ()\n\n@property (nonatomic, weak) IBOutlet UIView <\/span>*layerView;\n\n@end\n\n@implementation ViewController\n\n<\/span>- (void<\/span>)viewDidLoad\n{\n    [super viewDidLoad];\n    <\/span>\/\/<\/span>create sublayer<\/span>\n    CALayer *blueLayer = [CALayer layer];\n    blueLayer.frame <\/span>= CGRectMake(50.0f<\/span>, 50.0f<\/span>, 100.0f<\/span>, 100.0f<\/span>);\n    blueLayer.backgroundColor <\/span>= [UIColor blueColor].CGColor;\n    <\/span>\/\/<\/span>add it to our view<\/span>\n    [self.layerView.layer addSublayer:blueLayer];\n}\n@end<\/span><\/pre> \n <\/div> \n