Add lefthand margin to UITextField

You can do it by extending UITextField class and overriding two methods: – (CGRect)textRectForBounds:(CGRect)bounds; – (CGRect)editingRectForBounds:(CGRect)bounds; Here is the code: The interface in MYTextField.h @interface MYTextField : UITextField @end Its implementation in MYTextField.m @implementation MYTextField static CGFloat leftMargin = 28; – (CGRect)textRectForBounds:(CGRect)bounds { bounds.origin.x += leftMargin; return bounds; } – (CGRect)editingRectForBounds:(CGRect)bounds { bounds.origin.x += leftMargin; … Read more

Correct implementation of parent/child NSManagedObjectContext

The parent/child MOC model is a really powerful feature of Core Data. It simplifies incredibly the age-old concurrency problem we used to have to deal with. However, as you’ve stated, concurrency is not your issue. To answer your questions: Traditionally, you use the NSMainQueueConcurrencyType for the NSManagedObjectContext associated with the main thread, and NSPrivateQueueConcurrencyTypes for … Read more

How much delay of ios push notification?

Push notifications are unreliable and cannot be guaranteed that they have been delivered. It all depends on the apple APNS server, that said, usually when I send a push notification I get the result in under a few seconds. More Information: They are not reliable! There is no guarantee that push notifications will actually be … Read more

How to add Strings on X Axis in iOS-charts?

Hello recently I encountered the same problem and solved it this way- class ViewController: UIViewController { var months: [String]! var unitsSold = [Double]() weak var axisFormatDelegate: IAxisValueFormatter? @IBOutlet var viewForChart: BarChartView! override func viewDidLoad() { super.viewDidLoad() // Do any additional setup after loading the view, typically from a nib. axisFormatDelegate = self months = [“Jan”, … Read more

UITextView lineSpacing causes different cursor height inbetween paragraph lines

Finally I found a solution that solve my problem. Changing the cursor height is possible by subclassing the UITextView, then overriding the caretRectForPosition:position function. For example: – (CGRect)caretRectForPosition:(UITextPosition *)position { CGRect originalRect = [super caretRectForPosition:position]; originalRect.size.height = 18.0; return originalRect; } Documentation link: https://developer.apple.com/documentation/uikit/uitextinput/1614518-caretrectforposition Update: Swift 2.x or Swift 3.x See Nate’s answer. Update: Swift … Read more

UILabel: wrap and/or break inside word(s) with hyphen(s)

Elaborating on Matt’s answer here: https://stackoverflow.com/a/16502598/196358 it can be done using NSAttributedString and NSParagraphStyle. See below: NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc] init]; paragraphStyle.hyphenationFactor = 1.0f; NSMutableAttributedString *attributedString = [[NSMutableAttributedString alloc] initWithString:titleString attributes:@{ NSParagraphStyleAttributeName : paragraphStyle }]; self.titleLabel.attributedText = attributedString; This will cause the label to break at logical places mid-word using hyphens. It looks great, … Read more