Skip to content

Instantly share code, notes, and snippets.

View ikju's full-sized avatar
🏠
Working from home

Ik Ju Song ikju

🏠
Working from home
View GitHub Profile
func specificRangeRemove(str : String) -> String
{
var s : String = str
let range = s.index(s.startIndex, offsetBy: 8)..<s.endIndex
s.removeSubrange(range)
return s
}
이때까지 소셜로그인 하면,
AppDelegate 에, 이것저것 설정해 두었었다.
근데 iOS13 에서, 아무리 해도, 카카오 로그인 핸들러가 안불러지는것이다.
알고보니,
//UIActivityIndicatorView 변수 선언 하고 사용하는 방법
lazy var activityIndicator: UIActivityIndicatorView = {
// Create an indicator.
let activityIndicator = UIActivityIndicatorView()
activityIndicator.frame = CGRect(x: 0, y: 0, width: 50, height: 50)
activityIndicator.center = self.view.center
==========================================================================================================
If you already know the longest word you have to get the range of that word in the string.
I prefer the NSString method rangeOfString: for this.
You then create a NSMutableAttributedString from the string, with your default attributes.
Finally you apply highlighting attributes to the range you figured out earlier.
==========================================================================================================
let longString = "Lorem ipsum dolor. VeryLongWord ipsum foobar"
let longestWord = "VeryLongWord"
//변수 선언
private var refresh_control = UIRefreshControl()
// refreshControl 설정하기
private func refreshControl()
{
if #available(iOS 10.0, *)
{
home_collectionview.refreshControl = refresh_control
} else {
func doStringContainsNumber(string : String) -> Bool{
let numberRegEx = "^(?:|0|[1-9]\\d*)(?:\\.\\d*)?$"
let testCase = NSPredicate(format:"SELF MATCHES %@", numberRegEx)
let containsNumber = testCase.evaluate(with: string)
return containsNumber
}
print(doStringContainsNumber(string: "135-15"))
//false
func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAtIndex section: Int) -> UIEdgeInsets {
let totalCellWidth = CellWidth * CellCount
let totalSpacingWidth = CellSpacing * (CellCount - 1)
let leftInset = (collectionViewWidth - CGFloat(totalCellWidth + totalSpacingWidth)) / 2
let rightInset = leftInset
return UIEdgeInsets(top: 0, left: leftInset, bottom: 0, right: rightInset)
}
self.collectionView.reloadData()
self.collectionView.performBatchUpdates(nil, completion: {
(result) in
// ready reloadData가 실행되고 delegate 함수의 cellItemAt이 완료되면 이부분이 실행됩니다.
})
func textFieldDoneBtnMake(text_field : UITextField)
{//텍스트 입력할시 키보드 위에 done 기능 구현
let ViewForDoneButtonOnKeyboard = UIToolbar()
ViewForDoneButtonOnKeyboard.translatesAutoresizingMaskIntoConstraints = false
ViewForDoneButtonOnKeyboard.sizeToFit()
ViewForDoneButtonOnKeyboard.tintColor = .black
let btnDoneOnKeyboard = UIBarButtonItem(title: "Done", style: .plain, target: self, action: #selector(self.doneBtnFromKeyboardClicked))
ViewForDoneButtonOnKeyboard.items = [btnDoneOnKeyboard]
text_field.inputAccessoryView = ViewForDoneButtonOnKeyboard
let parameters : Parameters = ["id" : "아이디","password" : "비밀번호"]
// json에서 key값 설정
struct userlist: Codable {
var email : String
var result : String
}