분류 전체보기

func convertToCurrencyFormat(price: Int) -> String { let numberFormatter = NumberFormatter() numberFormatter.numberStyle = .decimal numberFormatter.maximumFractionDigits = 0 let result = numberFormatter.string(from: NSNumber(value: price)) ?? "" return result }
textView에서는 multi-line을 입력하기 때문에, 다음의 메서드를 추가하여 엔터 입력을 감지할 수 있다. func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool { guard text == "\n" else { return true } dismiss(animated: true) return true } 반환 값(Return Value) true >> if the old text should be replaced by the new text 이전 텍스트를 새 텍스트로 대체해야 할 경우 false >> if the replacement operation s..
import UIKit final class SourceTextViewController: UIViewController { private let placeholderText = "텍스트를 입력해주세요" private lazy var textView: UITextView = { let textView = UITextView() textView.text = placeholderText textView.textColor = .secondaryLabel textView.font = .systemFont(ofSize: 16, weight: .semibold) textView.returnKeyType = .done textView.delegate = self return textView }() override f..
· Processing
책에 있는 예제를 통해 픽셀에 대해 소개하겠습니다. 아래 예제는 화면 전체를 검게 만드는 소스입니다. loadPixels(); //이 함수는 화면에 보이는 내용을 조작 가능한 형태로 저장합니다. 이때 저장되는 배열은 pixels[]라는 이름의 배열입니다. for(int i = 0; i
· Processing
오늘은 이미지에 관해서 소개해 드리겠습니다. 다음은 이미지"straw"를 불러오는 코드입니다. PImage img; void setup(){ size(600,400); img=loadImage("straw.JPEG"); image(img,0,0); } void draw(){ } 아래는 이미지를 블러함수를 사용하여 블러링하는 것입니다. PImage img1, img2; void setup() { size(600,400); img1 = loadImage("straw.JPEG"); img2 = loadImage("straw.JPEG"); img2.filter(BLUR, 6); } void draw() { image(img1, 0, 0); image(img2, width/2, 0); } 다음은 수업을 응용하여 ..
· Processing
오늘은 마우스 인터랙션과 키보드 인터랙션을 소개해 드릴 예정입니다 ! 먼저 마우스 인터랙션에 사용되는 함수는 다음과 같습니다. - mouseClicked() : 마우스 버튼이 눌린 후 떨어질 때 실행된다. - mouseDragged() : 마우스 버튼이 눌린 채 드래그될 때 실행된다. - mouseMoved() : 마우스가 움직일 때 실행된다. - mouseReleased() : 마우스버튼이 떨어질 때 실행된다. - mouseWheel() : 마우스의 휠의 회전 숫자를 반환한다. - mousePressed() : 마우스가 클릭되면 자동으로 호출된다. 여기서 선형보간 함수 lerp()를 잠깐 소개하겠습니다. lerp(a, b, c)함수는 a위치부터 b위치까지 c만큼 값을 변경하는 함수입니다. 아래 예시를 ..
· Processing
아래는 배열을 응용한 위치가 바뀌며 커지는 원의 코드입니다 int [] arrayOfDiam; float [] arrayOfCentX, arrayOfCentY; void setup() { size(500, 500); background(255); //배열 변수들의 생성 arrayOfDiam = new int[10]; arrayOfCentX = new float[10]; arrayOfCentY = new float[10]; //10개의 배열 변수값 초기화 for (int i=0; i
· Processing
1. 선의 굵기 위치, 색상을 바꾸면서 화면 채우기 - 그라데이션 효과 size(512, 256); for( int i = 0; i
JINiOS
'분류 전체보기' 카테고리의 글 목록 (10 Page)