반응형

방법 1 :

// Swift (IOS10.3)
extension UIImage {
    func combineWith(image: UIImage) -> UIImage {
        let size = CGSize(width: self.size.width, height: self.size.height + image.size.height)
        UIGraphicsBeginImageContextWithOptions(size, false, 0.0)

        self.draw(in: CGRect(x:0 , y: 0, width: size.width, height: self.size.height))
        image.draw(in: CGRect(x: 0, y: self.size.height, width: size.width,  height: image.size.height))

        let newImage: UIImage = UIGraphicsGetImageFromCurrentImageContext()!
        UIGraphicsEndImageContext()

        return newImage
    }
}

// Usage
let image1 = UIImage(named: "image1.jpg")
let image2 = UIImage(named: "image2.jpg")
yourImageView.image = image1?.combineWith(image: image2)

 

방법 2 :

 

var bottomImage = UIImage(named: "bottom.png")
var topImage = UIImage(named: "top.png")

var size = CGSize(width: 300, height: 300)
UIGraphicsBeginImageContext(size)

let areaSize = CGRect(x: 0, y: 0, width: size.width, height: size.height)
bottomImage!.draw(in: areaSize)

topImage!.draw(in: areaSize, blendMode: .normal, alpha: 0.8)

var newImage:UIImage = UIGraphicsGetImageFromCurrentImageContext()!
UIGraphicsEndImageContext()
반응형

'개발 > iOS' 카테고리의 다른 글

Firebase dynamic link (다이나믹 링크) (2/4)  (0) 2021.06.17
Firebase dynamic link (다이나믹 링크) (1/4)  (2) 2021.06.17
시간 지연 함수  (0) 2021.03.18
경과 시간 구하기  (0) 2021.03.18
스크린 안꺼지게 하기  (0) 2021.03.18
블로그 이미지

SKY STORY

,

시간 지연 함수

개발/iOS 2021. 3. 18. 21:35
반응형

 

import UIKit

class CommonUtil : NSObject {
	static func delay(_ delay: Double, closure: @escaping ()->()) {
        	DispatchQueue.main.asyncAfter(
            		deadline: DispatchTime.now() + Double(Int64(delay * Double(NSEC_PER_SEC))) / Double(NSEC_PER_SEC),
			execute: closure
       		)
    	}
}


사용 방법 :
CommonUtil.delay(1.0, closure: { 
	/* do somthing */ 
})
반응형

'개발 > iOS' 카테고리의 다른 글

Firebase dynamic link (다이나믹 링크) (1/4)  (2) 2021.06.17
두개의 이미지 합치기  (0) 2021.03.18
경과 시간 구하기  (0) 2021.03.18
스크린 안꺼지게 하기  (0) 2021.03.18
스크린 캡쳐 이벤트  (0) 2021.03.18
블로그 이미지

SKY STORY

,

경과 시간 구하기

개발/iOS 2021. 3. 18. 21:34
반응형

 

import UIKit

class CommonUtil : NSObject {
        static func measure(closure: () -> Void) -> Float {
		#if !os(watchOS)
		let start = CACurrentMediaTime()
            	closure()
            	let end = CACurrentMediaTime()
            	#endif
            	return Float(end - start)
        }
}


사용 방법 :
let elapsedTime = CommonUtil.measure(closure: {
    for index in 0...100 { print("\(index)") }
})
print("elapsedTime = \(elapsedTime)")
// 0~100일 경우    : elapsedTime = 0.002251566


let elapsedTime = CommonUtil.measure(closure: {
    for index in 0...10000 { print("\(index)") }
})
print("elapsedTime = \(elapsedTime)")
// 0~10000일 경우  : elapsedTime = 0.06156574
반응형

'개발 > iOS' 카테고리의 다른 글

두개의 이미지 합치기  (0) 2021.03.18
시간 지연 함수  (0) 2021.03.18
스크린 안꺼지게 하기  (0) 2021.03.18
스크린 캡쳐 이벤트  (0) 2021.03.18
Universal Link (4/4) - 웹서버 환경 검증  (0) 2021.03.16
블로그 이미지

SKY STORY

,
반응형

어떠한 상황에 현재 페이지가 꺼지지 않게 해야하는 경우가 있다.

다음과 같이 구현하자.

 

Objective-C:
[[UIApplication sharedApplication] setIdleTimerDisabled: YES];

Swift (legacy):
UIApplication.sharedApplication().idleTimerDisabled = true

Swift 3 and above:
UIApplication.shared.isIdleTimerDisabled = true
반응형

'개발 > iOS' 카테고리의 다른 글

시간 지연 함수  (0) 2021.03.18
경과 시간 구하기  (0) 2021.03.18
스크린 캡쳐 이벤트  (0) 2021.03.18
Universal Link (4/4) - 웹서버 환경 검증  (0) 2021.03.16
Universal Link (3/4) - 웹서버 환경 설정  (0) 2021.03.16
블로그 이미지

SKY STORY

,
반응형

다음은 스크린 캡쳐 이벤트 처리 방법이다.

말 그대로 이벤트만 받는다. 막는건 안된다.

// Objective C
NSOperationQueue *mainQueue = [NSOperationQueue mainQueue];
[[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationUserDidTakeScreenshotNotification
                                                  object:nil
                                                   queue:mainQueue
                                              usingBlock:^(NSNotification *note) {
                                                 // executes after screenshot
                                              }];


// Swift
NotificationCenter.default.addObserver(
    forName: UIApplication.userDidTakeScreenshotNotification,
    object: nil,
    queue: .main) { notification in
        //executes after screenshot
}



방법 1
func detectScreenShot(action: @escaping () -> ()) {
    let mainQueue = OperationQueue.main
    NotificationCenter.default.addObserver(forName: UIApplication.userDidTakeScreenshotNotification, object: nil, queue: mainQueue) { notification in
        // executes after screenshot
        action()
    }
}


방법  2
func detectScreenShot(action: () -> ()) {
    let mainQueue = NSOperationQueue.mainQueue()
    NSNotificationCenter.defaultCenter().addObserverForName(UIApplicationUserDidTakeScreenshotNotification, object: nil, queue: mainQueue) { notification in
        // executes after screenshot
        action()
    }
}

방법1, 2 실행방법 
detectScreenShot { () -> () in
    print("User took a screen shot")
}
반응형
블로그 이미지

SKY STORY

,
반응형

환경 설정이 정상적으로 되어있는지 확인하려면 아래 사이트에서 가능하다.

 

Apple Search API Validation Tool 

https://search.developer.apple.com/appsearch-validation-tool

ex) 도메인이 'www.youtube.com'일 경우 검증

※ 주의 사항 : 

☞ 유니버셜링크는 앱링크 도메인이 등록된 앱이 스토어에 반영되어 있어야 하며 최도 등록시 활성화 되는데 최대 48시간의 시간이 걸릴  있다. (대부분 바로 적용 됨.)

☞ 위의 검증 사이트는 참고용으로만 사용한다. 정상적으로 동작하지만 경고를 출력하기도 한다. 예를들어 youtube.com은 정상으로 출력되나 google.com의 경우 오류가 뜬다. (참고만 할 것!)

 

 

Branch

https://branch.io/resources/aasa-validator/

Branch 와 Firebase 다이나믹 링크 비교

https://blog.branch.io/ko/branch가-firebase-다이나믹-링크를-대체할까요/

 

Apps Flyer

https://www.appsflyer.com/tools/app-links-validator/

 

Universal Link Validator

https://limitless-sierra-4673.herokuapp.com

 

yURL: Universal Links / AASA File Validator

https://yurl.chayev.com

 

 

※ 주의 사항

마지막으로, 테스트 도중 AASA파일을 수정했을 경우 앱은 이미 해당 파일을 앱 로컬 영역에 다운받아 캐싱되고 있으므로 변경된 사항이 적용되지 않았을 경우 다음과 같이 시도해 본다.

앱 삭제, 사파리의 '방문 기록 및 웹 사이트 데이터 지우기', 재부팅, 다시 앱 설치  이렇게 3번 반복!

이후 변경내용이 적용 된다. 

 

 

 

 

2021.03.16 - [iOS/Tips] - Universal Link (1/4) - 네이티브 환경설정

2021.03.16 - [iOS/Tips] - Universal Link (2/4) - 네이티브 링크 수신

2021.03.16 - [iOS/Tips] - Universal Link (3/4) - 웹서버 환경 설정

2021.03.16 - [iOS/Tips] - Universal Link (4/4) - 웹서버 환경 검증

2020.12.08 - [프로그래밍/Java Script] - Android, iOS 앱 설치여부 체크 및 스토어 이동

2021.06.17 - [iOS/Tips] - Firebase dynamic link (다이나믹 링크) (1/4)

2021.06.17 - [iOS/Tips] - Firebase dynamic link (다이나믹 링크) (2/4)

2021.06.17 - [iOS/Tips] - Firebase dynamic link (다이나믹 링크) (3/4)

2021.06.17 - [iOS/Tips] - Firebase dynamic link (다이나믹 링크) (4/4)

 

 

 

 

 

반응형
블로그 이미지

SKY STORY

,
반응형

스마트폰 BTC 채굴앱

https://get.cryptobrowser.site/34473645

 

Earn coins while browsing the web

Earn bitcoins while watching videos, chatting, or playing online. It has never been so easy to increase your income! Tell your friends about CryptoTab Browser, invite them to join, and earn more together. Grow your network—get more profit!

get.cryptobrowser.site

 

apple-app-site-association 파일 생성 및 작성

'appID' [App ID Prefix].[Bundle ID] 작성해 준다.

{
    "applinks": {
        "apps": [],
        "details": [
            {
                "appID": "M1ACL7W8FR.com.example.myapp",
                "paths": [ "*" ]
            }
        ]
    }
}

 

해당 파일을 도메인 루트에 복사 한다.

해당 파일이 정상적으로 접근 가능한지 테스트해 본다.

ex) 웹 브라우저에서 등록된 도메인 URL로 접근했을 때 작성된 json 정보가 출력되는지 확인한다.

https://www.youtube.com/apple-app-site-association

 

※ 주의 사항 :

☞ App ID Prefix 부분은 Team ID로 잘 못 기입하지 않도록 주의 한다. 일반적으로 이 부분은 Team ID와 동일하지만 다른 경우도 있으니 반드시 App ID Prefix를 확인하고 사용하도록 한다.

위의 AASA파일 생성 시 반드시 큰 따옴표( " )를 사용해야 한다. 또한 파일의 확장자는 붙이지 않는다.

 

스마트폰 BTC 채굴앱

https://get.cryptobrowser.site/34473645

 

Earn coins while browsing the web

Earn bitcoins while watching videos, chatting, or playing online. It has never been so easy to increase your income! Tell your friends about CryptoTab Browser, invite them to join, and earn more together. Grow your network—get more profit!

get.cryptobrowser.site

 

2021.03.16 - [iOS/Tips] - Universal Link (1/4) - 네이티브 환경설정

2021.03.16 - [iOS/Tips] - Universal Link (2/4) - 네이티브 링크 수신

2021.03.16 - [iOS/Tips] - Universal Link (3/4) - 웹서버 환경 설정

2021.03.16 - [iOS/Tips] - Universal Link (4/4) - 웹서버 환경 검증

2020.12.08 - [프로그래밍/Java Script] - Android, iOS 앱 설치여부 체크 및 스토어 이동

2021.06.17 - [iOS/Tips] - Firebase dynamic link (다이나믹 링크) (1/4)

2021.06.17 - [iOS/Tips] - Firebase dynamic link (다이나믹 링크) (2/4)

2021.06.17 - [iOS/Tips] - Firebase dynamic link (다이나믹 링크) (3/4)

2021.06.17 - [iOS/Tips] - Firebase dynamic link (다이나믹 링크) (4/4)

 

 

반응형
블로그 이미지

SKY STORY

,
반응형

iOS Deployment Target iOS 13이상 - Swift

class SceneDelegate: UIResponder, UIWindowSceneDelegate {
    ...
    func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
        // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
        // If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
        // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
        guard let _ = (scene as? UIWindowScene) else { return }
        
        
        // Get URL components from the incoming user activity.
        guard let userActivity = connectionOptions.userActivities.first,
              userActivity.activityType == NSUserActivityTypeBrowsingWeb,
              let incomingURL = userActivity.webpageURL,
              let components = NSURLComponents(url: incomingURL, resolvingAgainstBaseURL: true) else {
            return
        }
        print("url = \(incomingURL.absoluteString)")
        
        // Check for specific URL components that you need.
        guard let path = components.path,
              let params = components.queryItems else {
            return
        }
        print("path = \(path)")
        
        if let param = params.first(where: { $0.name == "param" })?.value {
            print("param = \(param)")
        } else {
            print("parsing error")
        }
    }
    ...
}

 

iOS Deployment Target iOS 13미만 - Swift

class AppDelegate: UIResponder, UIApplicationDelegate {
    ...
    func application(_ application: UIApplication,
                     continue userActivity: NSUserActivity,
                     restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool
    {
        // Get URL components from the incoming user activity.
        guard userActivity.activityType == NSUserActivityTypeBrowsingWeb,
        let incomingURL = userActivity.webpageURL,
        let components = NSURLComponents(url: incomingURL, resolvingAgainstBaseURL: true) else {
            return false
        }
        print("url = \(incomingURL.absoluteString)")
        
        // Check for specific URL components that you need.
        guard let path = components.path,
        let params = components.queryItems else {
            return false
        }
        print("path = \(path)")
        
        if let param = params.first(where: { $0.name == "param" })?.value {
            print("param = \(param)")
            return true
        } else {
            print("parsing error")
            return false
        }
    }
    ...
}

 

iOS Deployment Target iOS 13미만 - Objective-C

- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void(^)(NSArray *restorableObjects))restorationHandler
{
	...
	if ([userActivity.activityType isEqualToString:NSUserActivityTypeBrowsingWeb]) {
		NSString *url = userActivity.webpageURL.absoluteString;
		NSLog(@"url = %@", url);
		return YES;
	}
	...
	return NO;
}

 

2021.03.16 - [iOS/Tips] - Universal Link (1/4) - 네이티브 환경설정

2021.03.16 - [iOS/Tips] - Universal Link (2/4) - 네이티브 링크 수신

2021.03.16 - [iOS/Tips] - Universal Link (3/4) - 웹서버 환경 설정

2021.03.16 - [iOS/Tips] - Universal Link (4/4) - 웹서버 환경 검증

2020.12.08 - [프로그래밍/Java Script] - Android, iOS 앱 설치여부 체크 및 스토어 이동

2021.06.17 - [iOS/Tips] - Firebase dynamic link (다이나믹 링크) (1/4)

2021.06.17 - [iOS/Tips] - Firebase dynamic link (다이나믹 링크) (2/4)

2021.06.17 - [iOS/Tips] - Firebase dynamic link (다이나믹 링크) (3/4)

2021.06.17 - [iOS/Tips] - Firebase dynamic link (다이나믹 링크) (4/4)

 

반응형
블로그 이미지

SKY STORY

,