본문 바로가기

iOS

[swift] Util(UIImageView) UIImageViewExt public extension UIImageView { //ImageView Resize func imageResizeWithViewScale(_ respImage:UIImage) -> UIImage? { var retImage:UIImage? let imageWidth:CGFloat = respImage.size.width let imageHeight:CGFloat = respImage.size.height let viewWidth:CGFloat = self.frame.size.width let viewHeight:CGFloat = self.frame.size.height let ratioWidth:CGFloat = imageWidth / viewWidth let ratioH..
[swift] Util(UIImage) UIImageExt public extension UIImage { //Image resize width //ex -> image.widthScaledImage(maximumWidth:300) func widthScaledImage(maximumWidth: CGFloat) -> UIImage { let scale = maximumWidth / self.size.width let newHeight = self.size.height * scale UIGraphicsBeginImageContext(CGSize(width:maximumWidth, height:newHeight)) self.draw(in: CGRect(x: 0, y: 0, width:maximumWidth, height:newHeight)) le..
[swift] Util(String) StringExt public extension String { //Date format change //ex -> "20171201".date(inputFormat: "yyyyMMdd", outputFormat: "yyyy.MM.dd") func date(inputFormat: String, outputFormat:String) -> String? { if self.isEmpty { return ""} let dateFormatter = DateFormatter() dateFormatter.dateFormat = inputFormat if let date = dateFormatter.date(from: self) { dateFormatter.dateFormat = outputFormat return d..
[swift] iOS 주소 찾기 location 정보 사용 방법 findAddressWithType(type:.Street, lat: lat, lon: lon) { (str) in self?.myLocationLabel.text = str // "현위치 : " + str } 소스 public enum AddressType:String { case Name = "Name" //04309 대한민국 서울특별시 용산구 청파동2가 71-19 case ZipCode = "ZIP" //04309 case Country = "Country" //대한민국 case State = "State" //서울특별시 case City = "City" //용산구 case Street = "Street" //청파동2가 71-19 case Thoroughfare = ..
앱스토어 버전 가져오기 앱스토어 버전가져오기 NSDictionary *bundleInfo = [[NSBundle mainBundle] infoDictionary]; NSString *bundleIdentifier = [bundleInfo valueForKey:@"CFBundleIdentifier"]; NSURL *lookupURL = [NSURL URLWithString:[NSString stringWithFormat:@"http://itunes.apple.com/lookup?bundleId=%@", bundleIdentifier]]; NSData *lookupResults = [NSData dataWithContentsOfURL:lookupURL]; NSDictionary *jsonResults = [NSJSONSeriali..
iOS AudioSession 공부중.... AudioSession 이란 ? - iOS에서 뮤직/뮤비 플레이어를 만들때 스피커 및 마이크를 사용할수 있게 해주는 권한 사용 방법 [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayAndRecord withOptions:AVAudioSessionCategoryOptionDefaultToSpeaker error:nil]; 카테고리 종류 – AVAudioSessionCategorySoloAmbient : 디폴트로 앱이 실행되면 아이팟 오디오가 꺼지고 앱의 오디오만 작동됩니다. – AVAudioSessionCategoryAmbient : 앱이 실행되면 아이팟 오디오는 계속 실행되면서 앱의 오디오도 같이 작동합니다. (디폴트인듯.....
NSDate 대해서 1. 현재 시간 가져오기NSDate * date = [NSDate new]; date에는 현재시간, 날짜가 들어있다. 2. 원하는 NSString으로 가져오기 NSDate * date = [NSDate new]; NSDateFormatter * forMatter = [NSDateFormatter new]; [forMatter setDateFormat:@"yyyy-MM-dd HH:mm:ss.SSS"]; NSString *dateStr = [forMatter stringFromDate:date]; dateStr은 2015-05-06 20:43:30.000 이런식으로 나올것이다중간중간에 원하는 문자를 넣고싶으면 포멧형식사이에 '문자'를넣으면된다. [forMatter setDateFormat:@"yyyy-MM-..
apple mapKit 사용방(구글이 안해주는 길찾기기능 포함) 1. 사용되는 프레임워크 - MapKit.framework - CoreLocation.framework 2. 위치정보 사용은 첫번째 글 참고하세요^^ 3. 지도 사용하는 방법 MKMapView * mapView; MKCoordinateRegion region; CLLocationDegrees lat; CLLocationDegrees lon; if(_mapView ==nil){ _mapView = [[MKMapView alloc]initWithFrame:self.mainContentView.bounds]; } [_mapView setMapType:MKMapTypeStandard]; [_mapView setZoomEnabled:YES]; [_mapView setScrollEnabled:YES]; _mapVi..