leftalign

NSCollectionViewFlowLayout - left alignment

ε祈祈猫儿з 提交于 2020-01-12 09:17:46
问题 NSCollectionViewFlowLayout produces a layout with items justified on the right margin or, if the container is only wide enough for one item, centres items. I was expecting an alignment option, e.g. on the delegate, but am not finding anything in the docs. Does it require subclassing NSCollectionViewFlowLayout to achieve this? 回答1: Here is a subclass that produces a left justified flow layout: class LeftFlowLayout: NSCollectionViewFlowLayout { override func layoutAttributesForElementsInRect

NSCollectionViewFlowLayout - left alignment

你说的曾经没有我的故事 提交于 2020-01-12 09:17:40
问题 NSCollectionViewFlowLayout produces a layout with items justified on the right margin or, if the container is only wide enough for one item, centres items. I was expecting an alignment option, e.g. on the delegate, but am not finding anything in the docs. Does it require subclassing NSCollectionViewFlowLayout to achieve this? 回答1: Here is a subclass that produces a left justified flow layout: class LeftFlowLayout: NSCollectionViewFlowLayout { override func layoutAttributesForElementsInRect

Trouble left-aligning UIButton title (iOS/Swift)

≯℡__Kan透↙ 提交于 2019-12-04 15:09:09
问题 I'm having a problem left-aligning a UIButton 's text. I also tried changing it to .Right but it still stays centered. I also tried aButton.imageEdgeInsets = UIEdgeInsets(top: 0, left: 20, bottom: 0, right: 0) instead of aButton.titleLabel?.textAlignment = .Left but that doesn't change anything either. Is there an alternative way to programmatically change the alignment of a UIButton title's? allButtonViews = UIView(frame: CGRectMake(0, 44, 100, 100)) allButtonViews.backgroundColor =

QPushButton icon aligned left with text centered

醉酒当歌 提交于 2019-12-03 23:57:17
问题 In my Qt 5.7.1 application I've some buttons, I want to align button's icons to left and centre text, but there is no option in designer to do this. I can align icon and text left by adding to button stylesheet this code: text-align:left; But it's not what I want to achieve. So, could you please tell me, If there is any option to align icon to left, and keep text aligned center? Thank you for help. 回答1: Simply specialize QPushButton and override paintEvent and sizeHint , as proposed by

NSCollectionViewFlowLayout - left alignment

大兔子大兔子 提交于 2019-12-03 20:21:33
NSCollectionViewFlowLayout produces a layout with items justified on the right margin or, if the container is only wide enough for one item, centres items. I was expecting an alignment option, e.g. on the delegate, but am not finding anything in the docs. Does it require subclassing NSCollectionViewFlowLayout to achieve this? Obliquely Here is a subclass that produces a left justified flow layout: class LeftFlowLayout: NSCollectionViewFlowLayout { override func layoutAttributesForElementsInRect(rect: CGRect) -> [NSCollectionViewLayoutAttributes] { let defaultAttributes = super

Trouble left-aligning UIButton title (iOS/Swift)

别来无恙 提交于 2019-12-03 10:26:13
I'm having a problem left-aligning a UIButton 's text. I also tried changing it to .Right but it still stays centered. I also tried aButton.imageEdgeInsets = UIEdgeInsets(top: 0, left: 20, bottom: 0, right: 0) instead of aButton.titleLabel?.textAlignment = .Left but that doesn't change anything either. Is there an alternative way to programmatically change the alignment of a UIButton title's? allButtonViews = UIView(frame: CGRectMake(0, 44, 100, 100)) allButtonViews.backgroundColor = .redColor() let campusButton = UIButton(type: UIButtonType.System) as UIButton aButton.frame = CGRectMake(0, 0,

QPushButton icon aligned left with text centered

一世执手 提交于 2019-12-01 03:01:41
In my Qt 5.7.1 application I've some buttons, I want to align button's icons to left and centre text, but there is no option in designer to do this. I can align icon and text left by adding to button stylesheet this code: text-align:left; But it's not what I want to achieve. So, could you please tell me, If there is any option to align icon to left, and keep text aligned center? Thank you for help. Simply specialize QPushButton and override paintEvent and sizeHint , as proposed by cbuchart here . Then use it as a regular QPushButton . MyButton declaration and implementation: mybutton.h:

Add lefthand margin to UITextField

廉价感情. 提交于 2019-11-26 12:40:02
问题 I want to put the left margin of a UITextField \'s text at 10 px. What is the best way to do that? 回答1: As I have explained in a previous comment, the best solution in this case is to extend the UITextField class instead of using a category, so you can use it explicitly on the desired text fields. #import <UIKit/UIKit.h> @interface MYTextField : UITextField @end @implementation MYTextField - (CGRect)textRectForBounds:(CGRect)bounds { int margin = 10; CGRect inset = CGRectMake(bounds.origin.x