XCode中動態新增Label控制項

2021-09-08 16:20:37 字數 3638 閱讀 7613

uilabel *label =[[ uilabel alloc] init];

label.text = @"

***"

;label.frame = cgrectmake(0,0,100,100

) ;label.backgroundcolor =[uicolor redcolor];

//新增事件。

label.userinteractionenabled =yes;

uitapgesturerecognizer *singletap =[[uitapgesturerecognizer alloc] initwithtarget:self action:@selector(handlesingletap:)];

[label addgesturerecognizer:singletap];

[singletap release];

[self.view addsubview:label];

[label release] ;

//事件方法

- (void)handlesingletap:(uigesturerecognizer *)gesturerecognizer

#import

"labeltestviewcontroller.h

"@implementation

labeltestviewcontroller

/*accessing the text attributes

text property

font property

textcolor property

textalignment property

linebreakmode property

enabled property

sizing the label』s text

adjustsfontsizetofitwidth property

baselineadjustment property

minimumfontsize property 無例

numberoflines property

managing highlight values

highlightedtextcolor property

highlighted property

drawing a shadow

shadowcolor property

shadowoffset property

drawing and positioning overrides

– textrectforbounds:limitedtonumberoflines: 無例

– drawtextinrect: 無例

setting and getting attributes

userinteractionenabled property */

//implement viewdidload to do additional setup after loading the view, typically from a nib.

- (void

)viewdidload uilinebreakmode;

//如果adjustsfontsizetofitwidth屬性設定為yes,這個屬性就來控制文字基線的行為

label4.baselineadjustment =uibaselineadjustmentnone;

//typedef enum uibaselineadjustment;

[self.view addsubview:label1];

[self.view addsubview:label2];

[self.view addsubview:label3];

[self.view addsubview:label4];

[self.view addsubview:label5];

[self.view addsubview:label6];

[self.view addsubview:label7];

[label1 release];

[label2 release];

[label3 release];

[label4 release];

[label5 release];

[label6 release];

[label7 release];

[super viewdidload];

}

/*// override to allow orientations other than the default portrait orientation.

- (bool)shouldautorotatetointe***ceorientation:(uiinte***ceorientation)inte***ceorientation

*/

- (void

)didreceivememorywarning

- (void

)viewdidunload

- (void

)dealloc

@end

label中文字跑馬燈效果

uilabel *label = [[uilabel alloc] initwithframe:cgrectmake(10, 10, 300, 100

)]; label.text = @"

嚕啦啦嚕啦啦嚕啦嚕啦嚕,嚕啦嚕啦嚕啦嚕啦嚕啦嚕~~~";

[self.view addsubview:label];

cgrect frame =label7.frame;

frame.origin.x = -180

;label.frame =frame;

[uiview beginanimations:

@"testanimation

"context:null];

[uiview setanimationduration:

8.8f

];

[uiview setanimationcurve:uiviewanimationcurvelinear];

[uiview setanimationdelegate:self];

[uiview setanimationrepeatautoreverses:no];

[uiview setanimationrepeatcount:

999999

]; frame =label.frame;

frame.origin.x = 350

;label.frame =frame;

[uiview commitanimations];

Xcode 工程新增 動態Framework

1 xcode新增庫檔案framework 自己記錄一下,參考 首先先檢視一下framework中包含的結構 開啟mac終端,cd到靜態庫的位置,輸入命令 lipo info x.framework x這時候會顯示出該framework中所包含的架構 architectures in the fat...

ExtJS中如何給Label新增click事件

extjs中ext.form.label預設是沒有click事件的,但由於專案需要,要求給label新增一些其它的事件,本文提供兩種方法對這個class進行擴充套件,方法如下 方法1 ext.onready function ext.ux.mypanel ext.extend ext.panel,s...

Xcode6中新增pch檔案

1.新建工程 2 建立pch檔案 3 修改pch檔案,import 需要的標頭檔案 4 在setting中進行設定 5 pch標頭檔案的內容能被專案中的其他所有源檔案共享和訪問。pch檔案的作用 1.存放一些全域性的巨集 整個專案中都用得上的巨集 2.用來包含一些全部的標頭檔案 整個專案中都用得上的...