object-c 12

UIImageView Image ContentMode (비율)

//이미지를 중앙 비율을 맞추는것은 contentMode라고 한다//그에대한 자세한 설명은 http://marines.co.kr/archives/174 //contentMode Enum typedef NS_ENUM(NSInteger, UIViewContentMode) { UIViewContentModeScaleToFill, UIViewContentModeScaleAspectFit, // contents scaled to fit with fixed aspect. remainder is transparent UIViewContentModeScaleAspectFill, // contents scaled to fill with fixed aspect. some portion of content may be cl..

iOS/Objective C 2017.01.03

StoryBoard IB_DESIGNABLE

UIView+IB.h//h파일에 넣어주면 스토리보드에 UIView옵션이 생긴다.//그 옵션에 값을 넣어준다면 코딩으로 layer를 수정하지않아도 View생성시 값이 들어간다. 때에따라 자유롭게 사용하자.//(예) borderWidth#import IB_DESIGNABLE @interface UIView (IB) @property (nonatomic, assign) IBInspectable CGFloat borderWidth; @end UIView+IB.m#import "UIView+IB.h" IB_DESIGNABLE@implementation UIView (IB) //borderwidth make- (CGFloat)borderWidth;{ return self.layer.borderWidth;} - (v..

iOS/Objective C 2017.01.03

NSString UILabel 일부 문자열 배경색 변경

- (void) setBackgroundColor:(UILabel*)label { //테스트용 문자열 NSString* text = @"hello world!!!"; //문자열 설정 NSMutableAttributedString* att = [[NSMutableAttributedString alloc] initWithString:text]; //변화시킬 범위를 설정 NSRange range = [text rangeOfString:@"hello"]; //변화종류, 옵션 설정 [att addAttribute:NSBackgroundColorAttributeName value:[[UIColor greenColor] colorWithAlphaComponent:1.0f] range:range]; //설정내용으로 라..

iOS/Objective C 2015.12.23

NSString UILabel 일부 문자열 색상 변경

- (void) setTextColor:(UILabel*)label { //테스트용 문자열 NSString* text = @"hello world!!!"; //문자열 설정 NSMutableAttributedString* att = [[NSMutableAttributedString alloc] initWithString:text]; //변화시킬 범위를 설정 NSRange range = [text rangeOfString:@"hello"]; //변화종류, 옵션 설정 [att addAttribute:NSForegroundColorAttributeName value:[[UIColor brownColor] colorWithAlphaComponent:1.0f]//[UIColor brownColor]만 해도 사용이 ..

iOS/Objective C 2015.12.23

UILabel - 텍스트의 사이즈,색 바꾸기

더 좋은 방법이있다면 댓글에 남겨주세요~ NSMutableAttributedString* textFont = [[NSMutableAttributedString alloc] initWithString:[myLabel text]];//1 [textFont addAttribute:NSFontAttributeName value:[UIFont boldSystemFontOfSize:11] range:NSMakeRange(0,2)];//2 [myLabel setAttributedText:textFont];//3텍스트에 원하는 텍스트 크기를 조절하는 방법이다.1. 어느 텍스트를 바꿀것인지2. 텍스트의 폰트를 조절해주고 range를 설정해주면 range만큼 입력한 폰트로 변환된다. 3. 변화시킨뒤 다시 넣어주면 정상적으..

iOS/Objective C 2015.11.27