Skip to content

Instantly share code, notes, and snippets.

@satococoa
Created December 31, 2012 08:51
Show Gist options
  • Select an option

  • Save satococoa/4418356 to your computer and use it in GitHub Desktop.

Select an option

Save satococoa/4418356 to your computer and use it in GitHub Desktop.
class TaskView < UIView
attr_accessor :task, :title, :done, :memo
def initWithFrame(rect)
super.tap do |v|
@title = subview(UILabel,
text: 'タスク',
font: UIFont.fontWithName('HiraKakuProN-W6', size:128),
backgroundColor: UIColor.clearColor,
textColor: UIColor.whiteColor,
adjustsFontSizeToFitWidth: true)
end
end
def layoutSubviews
@title.frame = [
[30, 10],
[CGRectGetWidth(frame)-(30*2), CGRectGetHeight(frame)-(10*2)]
]
end
end
@satococoa

Copy link
Copy Markdown
Author

できればinitWithFrameの中でframeも済ませたいんだけど、TaskView.newが呼ばれるためにinitWithFrameの中ではrectが[[0, 0], [0, 0]]になってしまっている。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment