'iOS/Objective-C'에 해당되는 글 6건

728x90

UiView 에 대한 기초적인 내용을 공부하고 적어둔다.


Xcode 상에서 UIView 를 추가하는 그림



//

//  ViewController.m

//  AppView

//

//  Created by jsk005 on 2018. 12. 17..

//  Copyright © 2018 mchello. All rights reserved.

//


#import "ViewController.h"


@interface ViewController ()


@end


@implementation ViewController


- (void)viewDidLoad {

    [super viewDidLoad];

    

    // UIView 생성

    // [[객체타입 alloc]객체에 따른 생성 방법]

    // [[UIView alloc] initWithFrame:사각형]

    // [parent addSubView:child]; // 화면에 추가하기

    // [child removeFromSuperview]; // 화면에서 삭제하기

    

    // 화면에 보이는 것들의 기본 속성 : 사각형

    // CGRect

    // iOS 좌표계는 좌측 상단이 기준점이다.

    CGRect testRect = CGRectMake(10, 10, 100, 100); // x, y, width, height

    UIView *testView1 = [[UIView alloc] initWithFrame:testRect];

    testView1.backgroundColor = [UIColor redColor];

    [self.view addSubview:testView1];

    

    

    UIView *testView2 = [[UIView alloc] initWithFrame:CGRectMake(50, 150, 100, 100)];

    testView2.backgroundColor = [UIColor blueColor];

    [self.view addSubview:testView2];

    

    // 화면에 추가된 view 삭제하기

    //[testView1 removeFromSuperview];

    

    UIView *testView3 = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 20, 30)];

    testView3.backgroundColor = [UIColor redColor];

    [testView2 addSubview:testView3]; // UIView 상에다가 추가하기

    

    // 화면에서 숨기기

    //testView1.hidden = YES;

    testView2.hidden = NO; // YES 설정하면 testView3 같이 안보이게 된다.

    

    // 투명도

    testView1.alpha = 0.3; // alpha 0 hidden YES 같다.

    // hidden fade in, fade out 효과를 없다.

    

}


- (void)didReceiveMemoryWarning {

    [super didReceiveMemoryWarning];

    // Dispose of any resources that can be recreated.

}


@end 


실행결과 


'iOS > Objective-C' 카테고리의 다른 글

objective-c 객체 Type  (0) 2018.12.15
objective-c 함수  (0) 2018.12.12
objective C 변수 타입  (0) 2018.12.09
NSLog  (0) 2018.03.01
모바일 Web을 위한 아이콘 변환 사이트  (0) 2017.05.24
블로그 이미지

Link2Me

,
728x90

//

//  ViewController.m

//  object_make

//

//  Created by jsk005 on 2018. 12. 13..

//  Copyright © 2018 . All rights reserved.

//


#import "ViewController.h"


@interface ViewController ()


@end


@implementation ViewController


- (void)viewDidLoad {

    [super viewDidLoad];

    // 객체 : Alloc -> Init

    // 1. [[객체타입 alloc] 객체에 따른 생성 방법]

    // 2. [객체타입 객체에 따른 생성 방법]

    // 객체타입 *객체명 =

    

    // NSString

    NSString *myName = [[NSString alloc] initWithFormat:@"link2me."];

    NSLog(@"My Name is %@", myName);

    

    NSString *myCarName = [NSString stringWithFormat:@"New Pride."];

    NSLog(@"My CarName is %@", myCarName);

    

    // NSNumber

    NSNumber *myAge = [[NSNumber alloc] initWithInteger:33];

    NSLog(@" 나이 : %@", myAge);

    

    NSInteger changeAge = [myAge integerValue];

    NSLog(@"Integer 형식 변환 : %li",changeAge);

    

    NSNumber *myScore = [[NSNumber alloc] initWithFloat:89.53];

    NSLog(@" 수학점수 : %@", myScore);

    

    CGFloat changValue = [myScore floatValue];

    NSLog(@"Float 형식 변환 : %f", changValue);

    

}

- (void)didReceiveMemoryWarning {

    [super didReceiveMemoryWarning];

    // Dispose of any resources that can be recreated.

}


@end


'iOS > Objective-C' 카테고리의 다른 글

objective-c UIView 기초  (0) 2018.12.17
objective-c 함수  (0) 2018.12.12
objective C 변수 타입  (0) 2018.12.09
NSLog  (0) 2018.03.01
모바일 Web을 위한 아이콘 변환 사이트  (0) 2017.05.24
블로그 이미지

Link2Me

,

objective-c 함수

iOS/Objective-C 2018. 12. 12. 17:47
728x90

Objective-C 함수에 대해 간략하게 적어둔다.


- (return Type) 함수이:(Type)parameter1, 별칭:(Type) parameter2,... , 별칭:(Type) parametern

   {

        // 함수 body

   }



#import "ViewController.h"


@interface ViewController ()


@end


@implementation ViewController


// 함수

/* 리턴값이 없고 매개변수도 없는 함수

 - (void) 함수명 {

   do something ...

 }

 */

// 함수 호출

// [self 함수명];


/*

 // 매겨변수는 있고 리턴값은 없는 함수

 - (return Type) 함수명 : (매개변수 타입) 매겨변수명1

   두번째 값에 대한 설명:(매개변수 타입) 매겨변수명2

 {

    return Type 있으면 return returnValue;

    return Type 없으면 , void 리턴이 없음.

 }

 */


- (void) sumFunction1 : (NSInteger) firstValue {

    NSLog(@" 더하기 = %li", firstValue + 10);

}


- (void) sumFunction2 : (NSInteger) firstValue

      withValue:(NSInteger) secondValue

{

    NSLog(@"firsrtValue + secondValue = %li", firstValue + secondValue);

}


- (NSInteger) sumFunction3 : (NSInteger) firstValue

                  withValue:(NSInteger) secondValue

{

    NSInteger returnValue = firstValue + secondValue;

    return returnValue;

}


- (void)viewDidLoad {

    [super viewDidLoad];

    // Do any additional setup after loading the view, typically from a nib.

    

    // 함수에서 원하는 매개변수의 타입과 내가 함수를 호출하면서 넣어주는 값의 타입을 맞춰야 한다.

    [self sumFunction1:30];

    

    [self sumFunction2:10 withValue:30];

    

    NSLog(@"리턴값이 있는 함수 결과 : %li", [self sumFunction3:10 withValue:30]);

    

    }


- (void)didReceiveMemoryWarning {

    [super didReceiveMemoryWarning];

    // Dispose of any resources that can be recreated.

}


@end



'iOS > Objective-C' 카테고리의 다른 글

objective-c UIView 기초  (0) 2018.12.17
objective-c 객체 Type  (0) 2018.12.15
objective C 변수 타입  (0) 2018.12.09
NSLog  (0) 2018.03.01
모바일 Web을 위한 아이콘 변환 사이트  (0) 2017.05.24
블로그 이미지

Link2Me

,
728x90

//
//  main.m
//  Hello
//
//  Created by jsk005 on 2018. 12. 7..
//  Copyright (c) 2018년 link2me. All rights reserved.
//

#import <Foundation/Foundation.h>

int main(int argc, const char * argv[]) {
    @autoreleasepool {
       
        // 변수타입 변수명 = 값;
        // 변수명은 영어, 숫자, 정해진 특수문자(_ $)로만 작성한다.
        // 변수명은 가장앞에 숫자는 올 수 없다.
        // 변수명에 예약어는 사용할 수 없다.
        // 실제 변수명은 읽었을 때 이해가 되는 변수명을 사용하자.
       
        // 정수형 변수 타입 NSInterger, NSUInterger
        NSInteger myAge = 36;
        NSInteger myCarNo = 9560;
       
        NSLog(@"현재 나이 : %li",myAge);
        NSLog(@"내차번호 : %li", myCarNo);
       
        // 실수형 변수 타입 CGFloat
        CGFloat curTemperature = 36.5;
        CGFloat myWeight = 73.5;
       
        NSLog(@"현재 온도 : %f", curTemperature);
        NSLog(@"내 몸무게 : %f", myWeight);
       
        // BOOL 타입 변수 : YES(1), NO(0)
        BOOL isChild = YES;
        BOOL isWoman = NO;
       
        NSLog(@"아이입니까? : %li", isChild);
        NSLog(@"여자입니까? : %li", isWoman);


        // 사칙연산

        

        NSInteger a = 5;

        NSInteger b = 10;

        NSInteger c = a + b;

        

        NSLog(@"a - b = %li", a - b);

        NSLog(@"c value : %li", c);

        

        // 타입 캐스팅 : 미리 계산하기 전에 타입 캐스팅을 해줘야 한다.

        NSLog(@"a / b = %f", (CGFloat)a / (CGFloat)b);

        

        CGFloat myGrade = 87.5;

        CGFloat yourGrade = 90.3;

        CGFloat sumGrade = myGrade + yourGrade;

        

        NSLog(@"sumGrade = %.3f",sumGrade);

       
    }
    return 0;
}

'iOS > Objective-C' 카테고리의 다른 글

objective-c UIView 기초  (0) 2018.12.17
objective-c 객체 Type  (0) 2018.12.15
objective-c 함수  (0) 2018.12.12
NSLog  (0) 2018.03.01
모바일 Web을 위한 아이콘 변환 사이트  (0) 2017.05.24
블로그 이미지

Link2Me

,

NSLog

iOS/Objective-C 2018. 3. 1. 14:51
728x90

NSLog(@"The value of integer num is %i", num);   //integer %i 사용
NSLog(@"The value of Long number is %i", mlong);   //long %i 사용
NSLog(@"The value of float num is %.2f", _num);
//float에는 %f를 사용하고 소수점 이하 두자리만 출력하기 위해 %.2f 로 해줌
NSLog(@"The value of double num is %f", number);
//double에도 %f를 사용하며 (%g ,%G, %e ,%E(%e의 지수함수 형식) 로 표현할 수도 있음


NSDate *today= [NSDate date];
NSLog(@"the current date is %@",today);

return (0); // 0 값은 프로그램이 성공적으로 끝났다는 것을 나타내는 반환값

'iOS > Objective-C' 카테고리의 다른 글

objective-c UIView 기초  (0) 2018.12.17
objective-c 객체 Type  (0) 2018.12.15
objective-c 함수  (0) 2018.12.12
objective C 변수 타입  (0) 2018.12.09
모바일 Web을 위한 아이콘 변환 사이트  (0) 2017.05.24
블로그 이미지

Link2Me

,
728x90

아이콘을 변환하는 사이트를 찾으려고 하니 찾는데 좀 걸리기도 해서 적어둔다.


ico 파일로 아주 쉽게 변환해준다.


http://convertico.com/


http://icoconvert.com/


https://iconverticons.com/online/


모바일 Web 아이콘을 만드는 방법이다.

<link rel="apple-touch-icon" href="./images/touch-icon-iphone.png">


아이폰은 57×57 , 아이패드는 72×72, 아이폰4는 114×114 사이즈의 png 이미지를 사용한다.

가능하면 114×114 이미지로 만들어두면 아이폰에서 자동으로 크기 리사이즈를 한다.






'iOS > Objective-C' 카테고리의 다른 글

objective-c UIView 기초  (0) 2018.12.17
objective-c 객체 Type  (0) 2018.12.15
objective-c 함수  (0) 2018.12.12
objective C 변수 타입  (0) 2018.12.09
NSLog  (0) 2018.03.01
블로그 이미지

Link2Me

,