
1. 自定义显示问题 一种是直接继承就可以了,增加点属性,然后用drawrect或则增加subvIEws
另外一种就是通过category增加unbutton的方法:
在我们的 .h file:
在我们的 .m file:
@implementation UIbutton (Yourcategoryname)
@interface UIbutton (Yourcategoryname) -(voIDsetupbutton:(Nsstring*)Title imageUIImageimage description description; @end description { UILabel*TitleLabel =[[ alloc] initWithFrame:CGRectMake(100,020050)]];[self addSubvIEw:TitleLabel];[TitleLabel releaseUIImageVIEwimageVIEw initWithImage:[ imagenamedimageimageVIEwimageVIEw releasedescriptionLabel 60)];descriptionLabeldescriptionLabel release}
mybutton [ buttonWithTypeUIbuttonTypeCustom mybutton.frame 300); mybutton setupbuttonmyTitle imagemyImage descriptionmyDesc];2. 关于边框问题(IDinitWithFrameCGRect{ifself super initWithFrameframe]) selflayer setborderWIDth:1.0layer setCornerRadius5.0layer setbordercolor:[[UIcolor colorWithWhite0.3 Alpha0.7CGcolor]];}return self;}stretchableImageWithleftCapWIDth:topCapHeight:如果你设置了背景图片,那么需要把边框放在背景图片中,否则border应该是不生效的
When you set a background image in a button,the button outlines go away. Include them in your image,if you need different sizes look at the UIImage
method.
//数组快速过滤的方法
makeObjectsPerformSelector: is going to run that selector against every object in the array. If those objects are modifIEd by the selector they will be modifIEd. It does not return anything. Now,there is a catch,which that by default most copIEs in Cocoa are shallow copIEs,which means you get a new array,but the underlying objects it points to are the same objects. You will need to use initWithArray:copyItems to make it copy the root level items as well. If you want a new array containing the altered objects as well as the old array do something like this:
NSArraynewArray initWithArrayoldArray copyItemsYESnewArray makeObjectsPerformSelector@selectordoSomethingToObject:)];排序Use NSSortDescriptor like this..
is the array you want to sort. is another mutable array which has sorted dictionary values. Change the with the key value on which you have to sort.
如果是比较复杂的,需要再使用一个函数:NSSortDescriptordescriptor initWithKey:@"interest" ascendingstorIEs sortUsingDescriptors arrayWithObjectsdescriptornil recent storIEs copy storIEsrecent@"interest"Write a sort function that compares the relevant fIElds in two dictionarIEs. When you have this version you can for example use to sort your array.
Seehttp://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Classes/NSArray_Class/NSArray.html#//apple_ref/doc/uid/20000137-BBCHBAHB
Suppose there are 2 keys,integers ascending then and strings descending,then you may write
NSArray#sortedArrayUsingFunction:context:xyNSSortDescriptor dx "x" ascending dy "y"NO selectorcaseInsensitiveCompare:)];arr sortUsingDescriptorsx y nildx releasedy release];@H_668_404@ 总结以上是内存溢出为你收集整理的uibutton全部内容,希望文章能够帮你解决uibutton所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)