ios UIImage 图??居中

来源:本网整理

从图片中按指定的位置大小截取图片的一部分UIImage image 原始的图片CGRect rect 要截取的区域(UIImage*)imageFromImage:(UIImage*)image inRect:(CGRect)rect {CGImageRef sourceImageRef=[image CGImage];CGImageRef newImageRef=CGImageCreateWithImageInRect(sourceImageRef,rect);UIImage*newImage=[UIImage imageWithCGImage:newImageRef];return newImage;}www.zgxue.com防采集请勿采集本网。

<无详细内??gt; scrolltotop.offset(100,120); scrolltotop.init();

[1].[代码] [C/C++]代码 跳至[1]

   CGSize size = bgImg.size; UIGraphicsBeginImageContext(size); float dwidth = (self.view.frame.size.width - size.width) /2.0f; float dheight = 0; CGRect rect = CGRectMake(dwidth, dheight, size.width, size.height); [bgImg drawInRect:rect]; UIImage *newimg = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); SyntaxHighlighter.autoloader( 'applescript/js/sh309/scripts/shBrushAppleScript.js?t=1451961936000', 'actionscript3 as3/js/sh309/scripts/shBrushAS3.js?t=1451961936000', 'bash shell/js/sh309/scripts/shBrushBash.js?t=1451961936000', 'coldfusion cf/js/sh309/scripts/shBrushColdFusion.js?t=1451961936000', 'cpp c/js/sh309/scripts/shBrushCpp.js?t=1451961936000', 'obj-c objc/js/sh309/scripts/shBrushObjC.js?t=1451961936000', 'c# c-sharp csharp/js/sh309/scripts/shBrushCSharp.js?t=1451961936000', 'css/js/sh309/scripts/shBrushCss.js?t=1451961936000', 'delphi pascal/js/sh309/scripts/shBrushDelphi.js?t=1451961936000', 'diff patch pas/js/sh309/scripts/shBrushDiff.js?t=1451961936000', 'erl erlang/js/sh309/scripts/shBrushErlang.js?t=1451961936000', 'groovy/js/sh309/scripts/shBrushGroovy.js?t=1451961936000', 'haxe hx/js/sh309/scripts/shBrushHaxe.js?t=1451961936000', 'java/js/sh309/scripts/shBrushJava.js?t=1451961936000', 'jfx javafx/js/sh309/scripts/shBrushJavaFX.js?t=1451961936000', 'js jscript javascript/js/sh309/scripts/shBrushJScript.js?t=1451961936000', 'perl pl/js/sh309/scripts/shBrushPerl.js?t=1451961936000', 'php/js/sh309/scripts/shBrushPhp.js?t=1451961936000', 'text plain/js/sh309/scripts/shBrushPlain.js?t=1451961936000', 'py python/js/sh309/scripts/shBrushPython.js?t=1451961936000', 'ruby rails ror rb/js/sh309/scripts/shBrushRuby.js?t=1451961936000', 'scala/js/sh309/scripts/shBrushScala.js?t=1451961936000', 'sql/js/sh309/scripts/shBrushSql.js?t=1451961936000', 'vb vbnet/js/sh309/scripts/shBrushVb.js?t=1451961936000', 'xml xhtml xslt html/js/sh309/scripts/shBrushXml.js?t=1451961936000' ); SyntaxHighlighter.all();

CIImage 是CoreImage框架中 的 可以很好的处理图像效果 UIImage 是 UIKit框架中定义的图像类 封装了高层次的图像类 view是容器,image就是文件,就是数据,容器里面放数据。所以imageView.backgroundImage

我们使用下面这个图片作为按钮图片,这个图片的边缘没有任何白色的像素但是最后显示的效果确是这是放大后的效果,实际效果就是显示出两个很醒目的白点,我不知道这两个白点是如何出现的,原图中并没有UIImage*btnImage=[[UIImage alloc]initWithContentsOfFile:[[NSBundle mainBundle]pathForResource:@"button-add"ofType:@"png"]];UIButton*btn=[UIButton buttonWithType:UIButtonTypeCustom];btn.bounds=CGRectMake(0,0,btnImage.size.width,btnImage.size.height);[btn setImage:faceImage forState:UIControlStateNormal];以上是我用来画按钮的代码,是否针对透明的png图片,还有一些特殊的设置?内容来自www.zgxue.com请勿采集。

免责声明 - 关于我们 - 联系我们 - 广告联系 - 友情链接 - 帮助中心 - 频道导航
Copyright © 2017 www.zgxue.com All Rights Reserved