iOS中制作微信摇一摇的图框雏形

原创 2016年05月30日 15:17:56

模拟一下微信摇一摇的时候,两个图片上下滑动开,中间露出一朵小花的操作。

在这里用到的是触摸事件

对应的方法提示为:

<p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo;"><span style="font-variant-ligatures: no-common-ligatures">- (</span><span style="font-variant-ligatures: no-common-ligatures; color: #c32275">void</span><span style="font-variant-ligatures: no-common-ligatures">)motionBegan:(</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa">UIEventSubtype</span><span style="font-variant-ligatures: no-common-ligatures">)motion withEvent:(</span><span style="font-variant-ligatures: no-common-ligatures; color: #6122ae">UIEvent</span><span style="font-variant-ligatures: no-common-ligatures"> *)event</span></p>

动画的方法:

<p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(95, 49, 193);"><span style="font-variant-ligatures: no-common-ligatures; color: #6122ae">[UIView</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000"> </span><span style="font-variant-ligatures: no-common-ligatures">animateWithDuration</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">:</span><span style="font-variant-ligatures: no-common-ligatures; color: #0435ff">1.5</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000"> </span><span style="font-variant-ligatures: no-common-ligatures">animations</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">:^{</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(95, 49, 193);"><span style="font-variant-ligatures: no-common-ligatures; color: #000000"></span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo;"><span style="font-variant-ligatures: no-common-ligatures">     //先完成一个操作</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo;"><span style="font-variant-ligatures: no-common-ligatures">}</span><span style="font-variant-ligatures: no-common-ligatures; color: #5f31c1">completion</span><span style="font-variant-ligatures: no-common-ligatures">:^(</span><span style="font-variant-ligatures: no-common-ligatures; color: #c32275">BOOL</span><span style="font-variant-ligatures: no-common-ligatures"> finished) {</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(95, 49, 193);"><span style="font-variant-ligatures: no-common-ligatures; color: #000000">     //上面的操作完成后来完成这里面的操作</span></p>}];

transform方法

<p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(95, 49, 193);"><span style="font-variant-ligatures: no-common-ligatures">CGAffineTransformMakeTranslation</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">(</span><span style="font-variant-ligatures: no-common-ligatures; color: #0435ff">0</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">, </span><span style="font-variant-ligatures: no-common-ligatures; color: #0435ff">0</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">)</span></p>

下面是实现的代码:

<p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo;"><span style="font-variant-ligatures: no-common-ligatures">- (</span><span style="font-variant-ligatures: no-common-ligatures; color: #c32275">void</span><span style="font-variant-ligatures: no-common-ligatures">)loadView{</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo;"><span style="font-variant-ligatures: no-common-ligatures">    [</span><span style="font-variant-ligatures: no-common-ligatures; color: #c32275">super</span><span style="font-variant-ligatures: no-common-ligatures"> </span><span style="font-variant-ligatures: no-common-ligatures; color: #5f31c1">loadView</span><span style="font-variant-ligatures: no-common-ligatures">];</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(95, 49, 193);"><span style="font-variant-ligatures: no-common-ligatures; color: #000000">    </span><span style="font-variant-ligatures: no-common-ligatures; color: #c32275">self</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #539aa4">imageView</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000"> = [[</span><span style="font-variant-ligatures: no-common-ligatures; color: #6122ae">UIImageView</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000"> </span><span style="font-variant-ligatures: no-common-ligatures">alloc</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">] </span><span style="font-variant-ligatures: no-common-ligatures">initWithFrame</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">:[</span><span style="font-variant-ligatures: no-common-ligatures; color: #6122ae">UIScreen</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000"> </span><span style="font-variant-ligatures: no-common-ligatures">mainScreen</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">].</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa">bounds</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">];</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(112, 61, 170);"><span style="font-variant-ligatures: no-common-ligatures; color: #000000">    </span><span style="font-variant-ligatures: no-common-ligatures; color: #c32275">self</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #539aa4">imageView</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">.</span><span style="font-variant-ligatures: no-common-ligatures">backgroundColor</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000"> = [</span><span style="font-variant-ligatures: no-common-ligatures; color: #6122ae">UIColor</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000"> </span><span style="font-variant-ligatures: no-common-ligatures; color: #5f31c1">whiteColor</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">];</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(29, 148, 33);"><span style="font-variant-ligatures: no-common-ligatures">//    self.imageView.alpha = 0.1;</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo;"><span style="font-variant-ligatures: no-common-ligatures">    [</span><span style="font-variant-ligatures: no-common-ligatures; color: #c32275">self</span><span style="font-variant-ligatures: no-common-ligatures">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa">view</span><span style="font-variant-ligatures: no-common-ligatures"> </span><span style="font-variant-ligatures: no-common-ligatures; color: #5f31c1">addSubview</span><span style="font-variant-ligatures: no-common-ligatures">:</span><span style="font-variant-ligatures: no-common-ligatures; color: #c32275">self</span><span style="font-variant-ligatures: no-common-ligatures">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #539aa4">imageView</span><span style="font-variant-ligatures: no-common-ligatures">];</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo;"><span style="font-variant-ligatures: no-common-ligatures"><span style="color: rgb(29, 148, 33); font-size: 18px; white-space: pre; line-height: normal; font-family: Menlo; font-variant-ligatures: no-common-ligatures;">//</span><span style="color: rgb(29, 148, 33); font-family: 'PingFang SC'; font-size: 18px; white-space: pre; font-variant-ligatures: no-common-ligatures;">创建摇一摇背景的小花图</span>
</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo;"><span style="font-variant-ligatures: no-common-ligatures">    </span><span style="font-variant-ligatures: no-common-ligatures; color: #c32275">self</span><span style="font-variant-ligatures: no-common-ligatures">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #539aa4">backGround</span><span style="font-variant-ligatures: no-common-ligatures"> = [[</span><span style="font-variant-ligatures: no-common-ligatures; color: #6122ae">UIImageView</span><span style="font-variant-ligatures: no-common-ligatures"> </span><span style="font-variant-ligatures: no-common-ligatures; color: #5f31c1">alloc</span><span style="font-variant-ligatures: no-common-ligatures">] </span><span style="font-variant-ligatures: no-common-ligatures; color: #5f31c1">initWithFrame</span><span style="font-variant-ligatures: no-common-ligatures">:</span><span style="font-variant-ligatures: no-common-ligatures; color: #5f31c1">CGRectMake</span><span style="font-variant-ligatures: no-common-ligatures">(</span><span style="font-variant-ligatures: no-common-ligatures; color: #c32275">self</span><span style="font-variant-ligatures: no-common-ligatures">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #539aa4">imageView</span><span style="font-variant-ligatures: no-common-ligatures">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa">center</span><span style="font-variant-ligatures: no-common-ligatures">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa">x</span><span style="font-variant-ligatures: no-common-ligatures"> - </span><span style="font-variant-ligatures: no-common-ligatures; color: #0435ff">120</span><span style="font-variant-ligatures: no-common-ligatures">, </span><span style="font-variant-ligatures: no-common-ligatures; color: #c32275">self</span><span style="font-variant-ligatures: no-common-ligatures">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #539aa4">imageView</span><span style="font-variant-ligatures: no-common-ligatures">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa">center</span><span style="font-variant-ligatures: no-common-ligatures">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa">y</span><span style="font-variant-ligatures: no-common-ligatures"> - </span><span style="font-variant-ligatures: no-common-ligatures; color: #0435ff">200</span><span style="font-variant-ligatures: no-common-ligatures">, </span><span style="font-variant-ligatures: no-common-ligatures; color: #0435ff">240</span><span style="font-variant-ligatures: no-common-ligatures">, </span><span style="font-variant-ligatures: no-common-ligatures; color: #0435ff">400</span><span style="font-variant-ligatures: no-common-ligatures">)];</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(95, 49, 193);"><span style="font-variant-ligatures: no-common-ligatures; color: #000000">    </span><span style="font-variant-ligatures: no-common-ligatures; color: #6122ae">NSString</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000"> *flowerStr = [[</span><span style="font-variant-ligatures: no-common-ligatures; color: #6122ae">NSBundle</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000"> </span><span style="font-variant-ligatures: no-common-ligatures">mainBundle</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">]</span><span style="font-variant-ligatures: no-common-ligatures">pathForResource</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">:</span><span style="font-variant-ligatures: no-common-ligatures; color: #c91b13">@"flowers"</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000"> </span><span style="font-variant-ligatures: no-common-ligatures">ofType</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">:</span><span style="font-variant-ligatures: no-common-ligatures; color: #c91b13">@"png"</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">];</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo;"><span style="font-variant-ligatures: no-common-ligatures">    </span><span style="font-variant-ligatures: no-common-ligatures; color: #c32275">self</span><span style="font-variant-ligatures: no-common-ligatures">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #539aa4">backGround</span><span style="font-variant-ligatures: no-common-ligatures">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa">image</span><span style="font-variant-ligatures: no-common-ligatures"> = [</span><span style="font-variant-ligatures: no-common-ligatures; color: #6122ae">UIImage</span><span style="font-variant-ligatures: no-common-ligatures"> </span><span style="font-variant-ligatures: no-common-ligatures; color: #5f31c1">imageWithContentsOfFile</span><span style="font-variant-ligatures: no-common-ligatures">:flowerStr];</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(83, 154, 164);"><span style="font-variant-ligatures: no-common-ligatures; color: #000000">    [</span><span style="font-variant-ligatures: no-common-ligatures; color: #c32275">self</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">.</span><span style="font-variant-ligatures: no-common-ligatures">imageView</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000"> </span><span style="font-variant-ligatures: no-common-ligatures; color: #5f31c1">addSubview</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">:</span><span style="font-variant-ligatures: no-common-ligatures; color: #c32275">self</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">.</span><span style="font-variant-ligatures: no-common-ligatures">backGround</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">];</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: 'PingFang SC'; color: rgb(29, 148, 33);"><span style="line-height: normal; font-family: Menlo; font-variant-ligatures: no-common-ligatures;">//</span><span style="font-variant-ligatures: no-common-ligatures">创建摇一摇上图</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(95, 49, 193);"><span style="font-variant-ligatures: no-common-ligatures; color: #000000">    </span><span style="font-variant-ligatures: no-common-ligatures; color: #c32275">self</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #539aa4">topImageView</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000"> = [[</span><span style="font-variant-ligatures: no-common-ligatures; color: #6122ae">UIImageView</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000"> </span><span style="font-variant-ligatures: no-common-ligatures">alloc</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">] </span><span style="font-variant-ligatures: no-common-ligatures">initWithFrame</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">:</span><span style="font-variant-ligatures: no-common-ligatures">CGRectMake</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">(</span><span style="font-variant-ligatures: no-common-ligatures">CGRectGetMinX</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">(</span><span style="font-variant-ligatures: no-common-ligatures; color: #c32275">self</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #539aa4">backGround</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa">frame</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">), </span><span style="font-variant-ligatures: no-common-ligatures">CGRectGetMinY</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">(</span><span style="font-variant-ligatures: no-common-ligatures; color: #c32275">self</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #539aa4">backGround</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa">frame</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">), </span><span style="font-variant-ligatures: no-common-ligatures; color: #0435ff">240</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">, </span><span style="font-variant-ligatures: no-common-ligatures; color: #0435ff">200</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">)];</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(95, 49, 193);"><span style="font-variant-ligatures: no-common-ligatures; color: #000000">    </span><span style="font-variant-ligatures: no-common-ligatures; color: #6122ae">NSString</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000"> *up = [[</span><span style="font-variant-ligatures: no-common-ligatures; color: #6122ae">NSBundle</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000"> </span><span style="font-variant-ligatures: no-common-ligatures">mainBundle</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">] </span><span style="font-variant-ligatures: no-common-ligatures">pathForResource</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">:</span><span style="font-variant-ligatures: no-common-ligatures; color: #c91b13">@"up"</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000"> </span><span style="font-variant-ligatures: no-common-ligatures">ofType</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">:</span><span style="font-variant-ligatures: no-common-ligatures; color: #c91b13">@"png"</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">];</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(95, 49, 193);"><span style="font-variant-ligatures: no-common-ligatures; color: #000000">    </span><span style="font-variant-ligatures: no-common-ligatures; color: #c32275">self</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #539aa4">topImageView</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa">image</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000"> = [</span><span style="font-variant-ligatures: no-common-ligatures; color: #6122ae">UIImage</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000"> </span><span style="font-variant-ligatures: no-common-ligatures">imageWithContentsOfFile</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">:up];</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(83, 154, 164);"><span style="font-variant-ligatures: no-common-ligatures; color: #000000">    [</span><span style="font-variant-ligatures: no-common-ligatures; color: #c32275">self</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">.</span><span style="font-variant-ligatures: no-common-ligatures">imageView</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000"> </span><span style="font-variant-ligatures: no-common-ligatures; color: #5f31c1">addSubview</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">:</span><span style="font-variant-ligatures: no-common-ligatures; color: #c32275">self</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">.</span><span style="font-variant-ligatures: no-common-ligatures">topImageView</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">];</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; min-height: 21px;"><span style="font-variant-ligatures: no-common-ligatures"><span style="color: rgb(29, 148, 33); font-size: 18px; white-space: pre; line-height: normal; font-family: Menlo; font-variant-ligatures: no-common-ligatures;">//</span><span style="color: rgb(29, 148, 33); font-family: 'PingFang SC'; font-size: 18px; white-space: pre; font-variant-ligatures: no-common-ligatures;">创建摇一摇下图</span>    </span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(95, 49, 193);"><span style="font-variant-ligatures: no-common-ligatures; color: #000000">    </span><span style="font-variant-ligatures: no-common-ligatures; color: #c32275">self</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #539aa4">downImageView</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000"> = [[</span><span style="font-variant-ligatures: no-common-ligatures; color: #6122ae">UIImageView</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000"> </span><span style="font-variant-ligatures: no-common-ligatures">alloc</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">] </span><span style="font-variant-ligatures: no-common-ligatures">initWithFrame</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">:</span><span style="font-variant-ligatures: no-common-ligatures">CGRectMake</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">(</span><span style="font-variant-ligatures: no-common-ligatures">CGRectGetMinX</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">(</span><span style="font-variant-ligatures: no-common-ligatures; color: #c32275">self</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #539aa4">backGround</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa">frame</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">), </span><span style="font-variant-ligatures: no-common-ligatures">CGRectGetMidY</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">(</span><span style="font-variant-ligatures: no-common-ligatures; color: #c32275">self</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #539aa4">backGround</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa">frame</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">), </span><span style="font-variant-ligatures: no-common-ligatures; color: #0435ff">240</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">, </span><span style="font-variant-ligatures: no-common-ligatures; color: #0435ff">200</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">)];</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(95, 49, 193);"><span style="font-variant-ligatures: no-common-ligatures; color: #000000">    </span><span style="font-variant-ligatures: no-common-ligatures; color: #6122ae">NSString</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000"> *down = [[</span><span style="font-variant-ligatures: no-common-ligatures; color: #6122ae">NSBundle</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000"> </span><span style="font-variant-ligatures: no-common-ligatures">mainBundle</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">] </span><span style="font-variant-ligatures: no-common-ligatures">pathForResource</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">:</span><span style="font-variant-ligatures: no-common-ligatures; color: #c91b13">@"down"</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000"> </span><span style="font-variant-ligatures: no-common-ligatures">ofType</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">:</span><span style="font-variant-ligatures: no-common-ligatures; color: #c91b13">@"png"</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">];</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(95, 49, 193);"><span style="font-variant-ligatures: no-common-ligatures; color: #000000">    </span><span style="font-variant-ligatures: no-common-ligatures; color: #c32275">self</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #539aa4">downImageView</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa">image</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000"> = [</span><span style="font-variant-ligatures: no-common-ligatures; color: #6122ae">UIImage</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000"> </span><span style="font-variant-ligatures: no-common-ligatures">imageWithContentsOfFile</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">:down];</span> </p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(83, 154, 164);"><span style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);">    [</span><span style="font-variant-ligatures: no-common-ligatures; color: #c32275">self</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">.</span><span style="font-variant-ligatures: no-common-ligatures">imageView</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000"> </span><span style="font-variant-ligatures: no-common-ligatures; color: #5f31c1">addSubview</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">:</span><span style="font-variant-ligatures: no-common-ligatures; color: #c32275">self</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">.</span><span style="font-variant-ligatures: no-common-ligatures">downImageView</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">];</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo;"><span style="font-variant-ligatures: no-common-ligatures">}</span></p>
<p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo;"><span style="font-variant-ligatures: no-common-ligatures">- (</span><span style="font-variant-ligatures: no-common-ligatures; color: #c32275">void</span><span style="font-variant-ligatures: no-common-ligatures">)motionBegan:(</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa">UIEventSubtype</span><span style="font-variant-ligatures: no-common-ligatures">)motion withEvent:(</span><span style="font-variant-ligatures: no-common-ligatures; color: #6122ae">UIEvent</span><span style="font-variant-ligatures: no-common-ligatures"> *)event{</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(95, 49, 193);"><span style="font-variant-ligatures: no-common-ligatures; color: #000000">[</span><span style="font-variant-ligatures: no-common-ligatures; color: #6122ae">UIView</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000"> </span><span style="font-variant-ligatures: no-common-ligatures">animateWithDuration</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">:</span><span style="font-variant-ligatures: no-common-ligatures; color: #0435ff">1.5</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000"> </span><span style="font-variant-ligatures: no-common-ligatures">animations</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">:^{</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(95, 49, 193);"><span style="font-variant-ligatures: no-common-ligatures; color: #000000">    </span><span style="font-variant-ligatures: no-common-ligatures; color: #c32275">self</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #539aa4">topImageView</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa">transform</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000"> = </span><span style="font-variant-ligatures: no-common-ligatures">CGAffineTransformMakeTranslation</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">(</span><span style="font-variant-ligatures: no-common-ligatures; color: #0435ff">0</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">, -</span><span style="font-variant-ligatures: no-common-ligatures; color: #c32275">self</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #539aa4">topImageView</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa">frame</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa">size</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa">height</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">);</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: 'PingFang SC'; color: rgb(29, 148, 33);"><span style="line-height: normal; font-family: Menlo; font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);">    </span><span style="line-height: normal; font-family: Menlo; font-variant-ligatures: no-common-ligatures;">// </span><span style="font-variant-ligatures: no-common-ligatures">通过</span><span style="line-height: normal; font-family: Menlo; font-variant-ligatures: no-common-ligatures;">transform</span><span style="font-variant-ligatures: no-common-ligatures">设置平移举例</span><span style="line-height: normal; font-family: Menlo; font-variant-ligatures: no-common-ligatures;">x</span><span style="font-variant-ligatures: no-common-ligatures">为</span><span style="line-height: normal; font-family: Menlo; font-variant-ligatures: no-common-ligatures;">y</span><span style="font-variant-ligatures: no-common-ligatures">轴的平移距离</span><span style="line-height: normal; font-family: Menlo; font-variant-ligatures: no-common-ligatures;"> </span><span style="font-variant-ligatures: no-common-ligatures">正数往右</span><span style="line-height: normal; font-family: Menlo; font-variant-ligatures: no-common-ligatures;"> </span><span style="font-variant-ligatures: no-common-ligatures">负数往左</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: 'PingFang SC'; color: rgb(29, 148, 33);"><span style="line-height: normal; font-family: Menlo; font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);">    </span><span style="line-height: normal; font-family: Menlo; font-variant-ligatures: no-common-ligatures;">//y</span><span style="font-variant-ligatures: no-common-ligatures">为</span><span style="line-height: normal; font-family: Menlo; font-variant-ligatures: no-common-ligatures;">y</span><span style="font-variant-ligatures: no-common-ligatures">轴的平移距离</span><span style="line-height: normal; font-family: Menlo; font-variant-ligatures: no-common-ligatures;">  </span><span style="font-variant-ligatures: no-common-ligatures">正数往下</span><span style="line-height: normal; font-family: Menlo; font-variant-ligatures: no-common-ligatures;"> </span><span style="font-variant-ligatures: no-common-ligatures">负数往上</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(29, 148, 33);"><span style="font-variant-ligatures: no-common-ligatures; color: #000000">    </span><span style="font-variant-ligatures: no-common-ligatures">//transform</span><span style="line-height: normal; font-family: 'PingFang SC'; font-variant-ligatures: no-common-ligatures;">是与进行平移之前进行比较</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(95, 49, 193);"><span style="font-variant-ligatures: no-common-ligatures; color: #000000">    </span><span style="font-variant-ligatures: no-common-ligatures; color: #c32275">self</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #539aa4">downImageView</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa">transform</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000"> = </span><span style="font-variant-ligatures: no-common-ligatures">CGAffineTransformMakeTranslation</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">(</span><span style="font-variant-ligatures: no-common-ligatures; color: #0435ff">0</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">, </span><span style="font-variant-ligatures: no-common-ligatures; color: #c32275">self</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #539aa4">downImageView</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa">frame</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa">size</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa">height</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">);</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo;"><span style="font-variant-ligatures: no-common-ligatures">    }</span><span style="font-variant-ligatures: no-common-ligatures; color: #5f31c1">completion</span><span style="font-variant-ligatures: no-common-ligatures">:^(</span><span style="font-variant-ligatures: no-common-ligatures; color: #c32275">BOOL</span><span style="font-variant-ligatures: no-common-ligatures"> finished) {</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(95, 49, 193);"><span style="font-variant-ligatures: no-common-ligatures; color: #000000">        [</span><span style="font-variant-ligatures: no-common-ligatures; color: #6122ae">UIView</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000"> </span><span style="font-variant-ligatures: no-common-ligatures">animateWithDuration</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">:</span><span style="font-variant-ligatures: no-common-ligatures; color: #0435ff">1.5</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000"> </span><span style="font-variant-ligatures: no-common-ligatures">animations</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">:^{</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(95, 49, 193);"><span style="font-variant-ligatures: no-common-ligatures; color: #000000">            </span><span style="font-variant-ligatures: no-common-ligatures; color: #c32275">self</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #539aa4">topImageView</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa">transform</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000"> = </span><span style="font-variant-ligatures: no-common-ligatures">CGAffineTransformMakeTranslation</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">(</span><span style="font-variant-ligatures: no-common-ligatures; color: #0435ff">0</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">, </span><span style="font-variant-ligatures: no-common-ligatures; color: #0435ff">0</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">);</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo; color: rgb(95, 49, 193);"><span style="font-variant-ligatures: no-common-ligatures; color: #000000">            </span><span style="font-variant-ligatures: no-common-ligatures; color: #c32275">self</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #539aa4">downImageView</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">.</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa">transform</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000"> = </span><span style="font-variant-ligatures: no-common-ligatures">CGAffineTransformMakeTranslation</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">(</span><span style="font-variant-ligatures: no-common-ligatures; color: #0435ff">0</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">, </span><span style="font-variant-ligatures: no-common-ligatures; color: #0435ff">0</span><span style="font-variant-ligatures: no-common-ligatures; color: #000000">);</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo;"><span style="font-variant-ligatures: no-common-ligatures">         }</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo;"><span style="font-variant-ligatures: no-common-ligatures">       ];</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo;"><span style="font-variant-ligatures: no-common-ligatures">     }</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo;"><span style="font-variant-ligatures: no-common-ligatures">  ];</span></p><p style="margin-top: 0px; margin-bottom: 0px; font-size: 18px; line-height: normal; font-family: Menlo;"><span style="font-variant-ligatures: no-common-ligatures">}</span></p>



CorelDRAW中的图框改如何精确剪裁

CorelDRAW X7中的“图框精确剪裁”命令可以将对象置入到目标对象中,使对象按目标对象的外形进行精确剪裁,它可用来进行图像编辑、版式安排,在cdr软件中是一项非常重要的功能...
  • coreldraw2016
  • coreldraw2016
  • 2016年10月12日 13:12
  • 1571

STM32F103学习记录-----构建库函数雏形

固件库
  • uyouth_my
  • uyouth_my
  • 2017年01月15日 11:57
  • 340

自定义View,圆形图框

在很多App中有许多图框显示的是圆形的,但是在android系统中,控件默认的都是方形的;所以需要进行自定义view。 以下的代码是自定义圆形图框的代码;当需要的的时候,只需要把这个类放入自己的包下;...
  • yanfengcsdn
  • yanfengcsdn
  • 2016年05月13日 08:57
  • 125

iOS中制作动态链接库Framework

这几天在做个SDK遇到了很多问题,现在做完了想把制作Framework的过程分享出来(我这个SDK中也包含了其他的第三方很多Framework,所以踩了很多坑) 首先需要创建个Framework工程:...
  • qq_30970529
  • qq_30970529
  • 2016年03月14日 17:46
  • 2170

iOS - 教你制作SDK和.a静态库

转载自:http://blog.csdn.net/boring_cat/article/details/52807294 公司近期和其他公司合作 其他公司需要我们提供一个sdk等供给...
  • liangliang2727
  • liangliang2727
  • 2016年10月27日 05:39
  • 1676

iOS中动画的实现:以及视图的移动、缩放和旋转

一、动画和移动视图 IOS上实现动画的方式有多种,我们可以获得的最高层次的动画能力是通过UIKit,UIKit中包括一些Core Animation的较低层次的功能,并且包装成非常简洁的API供我们使...
  • qq348931837
  • qq348931837
  • 2013年09月18日 16:20
  • 1622

iOS framework制作 带你走出那些坑

iOS framework制作 Xcode8,带你走出那些坑
  • glt_code
  • glt_code
  • 2016年12月09日 15:20
  • 629

iOS中GIF的制作的简单版本记录

之前做过一个关于gif的app,一直没有来得及记录,现在记录一下学习的过程. 制作gif是基于ImageIO.framework,所以要先添加这个库 gif分解图片 ...
  • birthmarkqiqi
  • birthmarkqiqi
  • 2015年10月21日 16:27
  • 557

iOS制作演示gif

1.使用QuickTime、Simulator录制演示视频; 2.使用gif工具转换视频为gif。
  • kaka_2928
  • kaka_2928
  • 2016年05月26日 11:23
  • 819

ios开发:Xcode8制作framework及使用

网上关于Framework制作的教程数不胜数,然而都过于陈旧,最新的也是使用Xcode7的教程,而且有些设置也只给出步骤,并没有给出原因,而且按照有些教程制作出的framework还有些问题,所以我把...
  • dp948080952
  • dp948080952
  • 2016年10月07日 13:18
  • 12102
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:iOS中制作微信摇一摇的图框雏形
举报原因:
原因补充:

(最多只允许输入30个字)