OC 計算器 初級

2021-06-23 09:01:36 字數 2417 閱讀 4857

@inte***ce

@end

else

[containterview addsubview:button];}}

// 建立運算符號

nsarray *signarr = @[

@"+", @"-", @"*", @"/"

];for (int i = 0; i < 4; i ++)

// 建立清除按鈕

uibutton

*acbutton = [

uibutton

buttonwithtype:uibuttontypesystem];

acbutton.frame = cgrectmake(250, 160, 60, 60);

acbutton.backgroundcolor= [uicolor

graycolor];

[acbutton settitle:

@"ac"

forstate:uicontrolstatenormal];

[acbutton settitlecolor:[

uicolor

whitecolor] forstate:uicontrolstatenormal];

acbutton.titlelabel.font = [uifont

systemfontofsize:30];

acbutton.layer.cornerradius = 20;

[acbutton addtarget:

self

action:

@selector

(clear:) forcontrolevents:uicontroleventtouchupinside];

[containterview addsubview:acbutton];

// 建立等號按鈕

uibutton

*equalbutton = [

uibutton

buttonwithtype:uibuttontypesystem];

equalbutton.frame = cgrectmake(10, 480, 220, 60);

equalbutton.backgroundcolor = [uicolor

graycolor];

[equalbutton settitle:

@"="

forstate:uicontrolstatenormal];

[equalbutton settitlecolor:[

uicolor

whitecolor] forstate:uicontrolstatenormal];

equalbutton.titlelabel.font = [uifont

systemfontofsize:30];

equalbutton.layer.cornerradius = 20;

[equalbutton addtarget:

self

action:

@selector

(equal:) forcontrolevents:uicontroleventtouchupinside];

[containterview addsubview:equalbutton];

_string = [[nsmutablestring

alloc] init]; // 儲存輸入的數字 [

self

.window

makekeyandvisible];

return yes; }

- (void)send:(uibutton *)button

- (void)clear:(uibutton *)button

// = 號觸發事件

- (void)equal:(uibutton *)button

//判斷輸入是-號

if (_tempnumber == 2)

//判斷輸入是*號

if (_tempnumber == 3)

//判斷輸入是/號

if (_tempnumber == 4)

}// 符號觸發事件

- (void)sign:(uibutton *)button

//判斷輸入是-號

if([[button currenttitle] isequaltostring:

@"-"])

//判斷輸入是*號

if([[button currenttitle] isequaltostring:

@"*"])

//判斷輸入是/號

if([[button currenttitle] isequaltostring:

@"/"])

}// 後退觸發事件

- (void)back:(uibutton *)button

}

實現計算器

dim boldot as boolean dim dblacc1,dblacc2 as double dim dblacc3 as double 10 dim strop as string private sub add num byval intnumber as integer if bol...

計算器修改

在做計算器介面修改這個專案中遇見的問題。先把需求說清楚,黑莓風格的計算器裡面有觸控和非觸控兩個流程。介面,功能,和座標是不一樣的。我是要在非觸控下做出觸控螢幕的介面,除了不能觸控以外,所有的功能都要和觸控螢幕下一樣。之前先是找到資源,然後替換資源,載入,調座標,調功能,調bug。資源很快就找到了,然...

簡單計算器

unit unit1 inte ce uses windows,messages,sysutils,variants,classes,graphics,controls,forms,dialogs,stdctrls,buttons,math math是數 算單元 type tform1 class ...