iOS 썸네일형 리스트형 [swift] UITextView글자수 제한(붙여넣기) func textView(_ textView: UITextView, shouldChangeTextIn range: NSRange, replacementText text: String) -> Bool { let newText = (textView.text as NSString).replacingCharacters(in: range, with: text) let numberOfChars = newText.count if(numberOfChars > 200){ let leng = 200 - textView.text.characters.count textView.text = (textView.text as NSString).replacingCharacters(in: range, with: text.substri.. [swift] 정규식 정규식 체크 func checkString(newText:String, filter:String = "[a-zA-Z0-9가-힣ㄱ-ㅎㅏ-ㅣ\\s]") -> Bool { let regex = try! NSRegularExpression(pattern: filter, options: []) let list = regex.matches(in:newText, options: [], range:NSRange.init(location: 0, length:newText.count)) if(list.count != newText.count){ return false } return true } [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 : 앱이 실행되면 아이팟 오디오는 계속 실행되면서 앱의 오디오도 같이 작동합니다. (디폴트인듯..... 이전 1 2 3 4 다음